Below is a bit of code which produces the following text:
TestHello. Here
Testis some text
Testwhich is on the screen.
What I would like to know is how the fgets function ends the string. Does it just stop, or is it automatically null terminated? i.e. for the first line of my output would s[13] = 0?
Code:#include <stdio.h> int main() { FILE *f; char s[1000]; f=fopen("file.txt","r"); if (!f) return 1; while (fgets(s,1000,f)!=NULL) { printf("Test"); printf("%s",s); } fclose(f); return 0; }