首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

请问一个有关问题,想要在LIST输出,应该如何改

2012-04-10 
请教一个问题,想要在LIST输出,应该怎么改?void CNBTSTATDlg::OnBnClickedStatis(){BOOL ReadTxt(string st

请教一个问题,想要在LIST输出,应该怎么改?
void CNBTSTATDlg::OnBnClickedStatis()
{
   

BOOL ReadTxt(string strFilePath, map< string, int> &IPCount_map);
  map< string, int> IPCount_map;
  string strFilePath = "E:\bs\Graduation project_2012_3_8_19\IP.txt";
  ReadTxt(strFilePath, IPCount_map);
  for(map< string, int>::iterator iter = IPCount_map.begin(); iter != IPCount_map.end(); ++iter)//遍历
  {
 
 
printf("%s ---- %d个\n", iter->first.c_str(), iter->second);


  //return 0;


}  
   

BOOL ReadTxt(string strFilePath, map< string, int> &IPCount_map)
{
  char buf[100] = {0};
  int i = 0, ch = 0;
  errno_t err;
  FILE *stream = NULL;
  if( (err = fopen_s(&stream, strFilePath.c_str(), "r")) != 0 )
  {
  printf("ERROR: Open or read %s is Error\n", strFilePath.c_str());
  return FALSE;
  }
  ch = fgetc( stream );
  while(feof( stream ) == 0)//读取每行数据
  {
  buf[i] = (char)ch;
  if(buf[i] == '\n')
  {
  buf[i] = '\0';
  string strLine = buf;
  IPCount_map[strLine]++;//IP计数
  i = 0;
  }
  ch = fgetc( stream );
  i++;
  }
  fclose( stream );
  return TRUE;
}
这个代码想要实现,按键后输出IP.txt中不同IP地址分别的个数在LIST输出,不知道应该怎么改

[解决办法]
把你要输出的用CString::Format组织好 然后调用listbox的AddString即可

热点排行