getchar() in C language URGENT

Status
Not open for further replies.

raul260291

Junior Member level 1
Joined
Jul 1, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,389
Normally while reading a text file we use a loop command
while((c=getchar()) != EOF)
and when it reaches the EOF the loop breaks.

Question : Is there any way that we can jump the control again to the beginning of the text file so that c=getchar() begins again???
 

Hi, I think you are going to have to clear/close the file you just read and reopen it again since it is already at eof.
 

Hello!

Hi, I think you are going to have to clear/close the file you just read and reopen it again since it is already at eof.

No, you don't have to close the file. You can use ftell, fseek.

- ftell tells you the position of the reading point
- fseek sets the position.

If you do : seek(f0, 0, 0), then you're back to the beginning of the file.

Dora.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…