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.
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.
Whats the problem???Take a file pointer as
FILE *fp;
fp=fopen("<path>","<permission>");
//error check
Just like death_oclock said call a rewind and it will take you to the top of the file. rewind(fileName);
Cheers
No, you don't pass in the filename; you pass an already opened file pointer (FILE *).
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.
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.