16,473
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("list.txt");
string s;
while(getline(fin,s))
cout << s << endl;
fin.close();
return 0;
}
ifstream myfile;
CFileException fileException;
CString FileData;
DWORD dwError;
if(myfile.open(FileName, ios::in|ios::out),&fileException)
{
while (!myfile.eof())
{
CString FileData;
char data[165]="";
myfile.getline(data,165);
FileData=data;
{
WritePrivateProfileString("FIT","NUM","11111","C:\\xuliehao.ini");
return 0;
}
}
}
dwError = GetLastError();
if (dwError != ERROR_NO_MORE_FILES)
{
return -1;
}
return 0;
结果每次读出都是空的数据#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("list.txt");
string s;
while(fin.getline(fin,s))
cout << s << endl;
fin.close();
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char a[1][100];
FILE *file;
file= fopen ("cc.txt","w");
fprintf( file, "%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n","0","0","0 1","0","0","0 g","0! 1a ");
fclose(file);
file= fopen ("cc.txt","r");
while (!feof(file)){
fscanf(file, "%[^\r\n]\r\n", a[0]);
printf("%s %d\n",a[0],strlen(a[0]));
}
system("pause");
return 0;
}