主题:求如何在文本编辑器中实现统计字母数功能
soul2004
[专家分:0] 发布于 2006-06-08 16:54:00
一个可以读、存、写的文本编辑器,支持TXT格式,不支持中文输入。请问如何实现一个功能,统计文本中各字母的数量,比如,字母“a”有多少个,"b"有多少个。
-----------------------------------------------------------------------------
在文本编辑器中实现统计字母功能,文本编辑器部分代码如下:
case WM_COMMAND:
...
switch (LOWORD (wParam))
{....
case IDM_FORMAT_COUNT:
//然后在这里就是我求的统计功能函数啦
return 0;
...
}
求救啊~~
5 楼
soul2004 [专家分:0] 发布于 2006-06-08 19:18:00
我试了一下午都不行。你给我的代码有时编译通过,有时又有9个警告。我只晕。警告如下:
d:\program files\microsoft visual studio\vc98\include\xtree(182) : warning C4786: 'std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::~_Tree<char,std::pair<
char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information
d:\program files\microsoft visual studio\vc98\include\xtree(162) : warning C4786: 'std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::_Tree<char,std::pair<c
har const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information
d:\program files\microsoft visual studio\vc98\include\xtree(236) : warning C4786: '__ehhandler$?insert@?$_Tree@DU?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@QAE?AU?$pair@Viterator@?$_Tree@DU
?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@_N@2@ABU?$pair@$$CBDH@2@@Z' : identifier was truncated to '255' characters in the debug information
d:\program files\microsoft visual studio\vc98\include\xtree(236) : warning C4786: '__unwindfunclet$?insert@?$_Tree@DU?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@QAE?AU?$pair@Viterator@?$_Tre
e@DU?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@_N@2@ABU?$pair@$$CBDH@2@@Z$0' : identifier was truncated to '255' characters in the debug information
d:\program files\microsoft visual studio\vc98\include\utility(21) : warning C4786: 'std::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,bo
ol>::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,bool>' : identifier was truncated to '255' characters in the debug information
count.obj - 0 error(s), 9 warning(s)
然后我下午也把他改成一个函数加去后编译又出现这样的错:
Compiling...
PopCount.cpp
d:\c++project\poppad3\popcount.cpp(7) : error C2220: warning treated as error - no object file generated
d:\c++project\poppad3\popcount.cpp(7) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,std:
:pair<char const ,int>,std::pair<char const ,int> &,std::pair<char const ,int> *,int>' : identifier was truncated to '255' characters in the debug information
d:\c++project\poppad3\popcount.cpp(7) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::const_iterato
r,std::pair<char const ,int>,std::pair<char const ,int> const &,std::pair<char const ,int> const *,int>' : identifier was truncated to '255' characters in the debug information
d:\c++project\poppad3\popcount.cpp(7) : warning C4786: 'std::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,std::_Tree<char,std::pair<char
const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator>' : identifier was truncated to '255' characters in the debug information
d:\c++project\poppad3\popcount.cpp(7) : warning C4786: 'std::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::const_iterator,std::_Tree<char,std::pai
r<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::const_iterator>' : identifier was truncated to '255' characters in the debug information
Error executing cl.exe.
PopCount.obj - 1 error(s), 4 warning(s)
要不我把整个代码发给你你帮我整~
[em2]