Mixing C and C++ to read a file is not really recommended. It works at the beginning but it seems by seeking on stdin
, it gets de-synchronized with cin
which is always at the end of file. Since you did everything in C, here's a version that work using scanf instead:
int main(){
char s0[256];
char name[256];
char filename[256];
freopen("windmill02.mtl", "r", stdin);
for (int i=0; i<2; i++) {
fseek(stdin, 0, 0);
while (!feof(stdin)) {
scanf("%s", s0);
scanf("%s", name);
scanf("%s", filename);
cout << name << " " << filename << endl;
}
}
fclose(stdin);
return 0;
}