C
cylin
Dear all,
I can use c language function fscanf() to get a char. string.
Ex:
FILE *file=fopen("test.txt","r");
char data[100];
while (!feof(file)) {
fscanf(file,"%s",data);
...
}
fclose(file);
--------------------------------------------------------
But if using c++, how to get? I always get a whole line such as using
getline(), not a char. string.
Ex:
ifstream file;
file.open("test.txt",ios::in);
char data[100];
while (!file.eof()) {
file.get(????)------------------------------------------->????????????
...
}
file.close();
I can use c language function fscanf() to get a char. string.
Ex:
FILE *file=fopen("test.txt","r");
char data[100];
while (!feof(file)) {
fscanf(file,"%s",data);
...
}
fclose(file);
--------------------------------------------------------
But if using c++, how to get? I always get a whole line such as using
getline(), not a char. string.
Ex:
ifstream file;
file.open("test.txt",ios::in);
char data[100];
while (!file.eof()) {
file.get(????)------------------------------------------->????????????
...
}
file.close();