How do you reset scanf() to read the beginning of the text without the use of fopen or fclose.
I have a stage 1 which reads half of the text file and stage 2 requires me reset the scanf() to beginning of the text and read it all the way.
Any tips or guidance is appreciated.
You Guys are the best!
EDIT: The text has ONLY numbers in it and the file is opened via /myprogram <txt.txt.
You can use fseek() or rewind().
rewind(fp);
or
fseek(fp, 0, SEEK_SET);
One can use rewind(FILE *fp) to reset the position to beginning of the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With