首页
社区
课程
招聘
[求助]百思不得其解,求指点,一个小问题
发表于: 2012-1-11 00:43 3398

[求助]百思不得其解,求指点,一个小问题

2012-1-11 00:43
3398
以下的这段代码本来用来逐行读取记事本,并在读取一行后对该行的情况进行统计(查看0的个数),如果0的个数大于一定值,输出该行,否则不输出;求指点。。。。
问题如下:①没有好的方法调试,vc6情况下调试时open函数的输入输出流会停在sourcecode的文档中,导致open函数无法正常打开文档
②读取之后满足不了上述的功能
// print the content of a text file.
#include <iostream>
#include <fstream>
#include<string>
using namespace std;

int main () {

  ifstream infile;
  string str;
  

  infile.open ("test.txt", ifstream::in);

  //int ch = infile.get();
  //getline(infile,str);
  //while (infile.good()) {
  //  cout << (char) ch;
    //ch = infile.get();
  //}
  while(getline(infile,str)){
  
          for(int i=0;i<10;i++){
          
                  int temp=0;
                  if((int)(str[i])==48){
                  
                          //int temp=0;
                          temp=temp+1;

                  }

                  if(temp>6){
                  
                          cout<<str<<endl;

                  }
                  //cout<<str<<endl;
          }

  }
  infile.close();
  system("pause");

  return 0;
}

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 9
活跃值: (12)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
发现问题,temp位置有问题
2012-1-11 08:36
0
雪    币: 2120
活跃值: (73)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
3
int temp=0; // 应该在for循环外面
2012-1-12 13:07
0
游客
登录 | 注册 方可回帖
返回
//