-
-
[求助]百思不得其解,求指点,一个小问题
-
发表于:
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作者讲授!