0
How file pointer works?
This might be silly question but how file pointer works ? I have this program here it reads content from file char by char. so as file pointer is intialise at 1st char of txt file how it get incremented to next char? I'm not doing any increment here. https://code.sololearn.com/c5ZlqgnVZT3s/?ref=app
2 Respostas
+ 3
while((ch = fgetc(fp)) != EOF)
printf("%c", ch);
EOF is end of file. just like we know '\0' is EOF. so it will keep reading a file until meet EOF.
then, you close it fclose().
why? while writing file, the file is locked and will not unlocked until fclose(). so if you forget fclose, probally bugs will come when you try to access that file with another program
0
Well I don't think u understand my question.
and I'm already using fclose() what's problem with that ?