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

30th May 2018, 2:12 PM
Yugabdh
Yugabdh - avatar
2 Réponses
+ 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
7th Jun 2018, 4:02 PM
Kevin AS
Kevin AS - avatar
0
Well I don't think u understand my question. and I'm already using fclose() what's problem with that ?
8th Jun 2018, 11:43 AM
Yugabdh
Yugabdh - avatar