64,648
社区成员
发帖
与我相关
我的任务
分享
string line;
ifstream infile("a.txt");
while(getline(infile,line))
{
cout<<line<<endl;
}
string file_name;
ifstream infile("G:\\1.txt",ios::in);
string textline = "";
string aa[256] ;
int i = 0;
while(getline(infile,textline,'\n'))
{
i = i + 1;
aa[i] = textline;
cout<<textline<<endl;
}
cout<<i;
for(int j = 0; j<=i;j++)
{
cout<<aa[j]<<endl;
}
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream infile;
char s[256];
fp.open("d:\\stu.txt");
if( fp == NULL )
{
cout<<"Can't open the file"<<endl;
exit(0);
}
while(1)
{
infile.getline(s,256); //这种调用,参数不同!
if( infile.eof())
break;
cout<<s<<endl;
}
return 0;
}
string file_name;
ifstream infile(file_name.c_str(),ios::in);
string textline;
while(getline(infile,textline,'\n'))//遇到换行结束这一行的读取,只要不到文件最后,就一直读下去
// open log file
ifstream input("E:\001.txt", ios::in);
if(input.good())
{
while(!input.fail()) //结束判断
{
char *cValue = new char[255];
input.getline(cValue,255);
}
}
string file_name;
ifstream infile(file_name.c_str(),ios::in);
string textline;
getline(infile,textline,'\n')//遇到换行结束这一行的读取
char buf[255];
FILE* file = fopen("C:\\Documents and Settings\\Administrator\\桌面\\test.txt","rb");
while (fgets(buf,255,file))
{
int x = 1;
x*=1;
}
fclose(file);