0

What way(s) can I reread the same file in C? I've only been able to find C++ tutorials. I tried:

fclose(infile);
infile = fopen(argv[1], "r");
//error checking

but this code didn't go to the beginning of the file.

5
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by kenji
0

Whats the problem???Take a file pointer as

FILE *fp;
fp=fopen("<path>","<permission>");
//error check

0

Just like death_oclock said call a rewind and it will take you to the top of the file. rewind(fileName); Cheers

0

What way(s) can I reread the same file in C? I've only been able to find C++ tutorials. I tried:

fclose(infile);
infile = fopen(argv[1], "r");
//error checking

but this code didn't go to the beginning of the file.

Any time you open a file you are automatically at the beginning of the file. So I don't understand what the problem is.

0

No, you don't pass in the filename; you pass an already opened file pointer (FILE *).

Thats what I meant wrote it down in a hurry. Will go back and correct it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.