So I was wondering, how can I read only a part of a text file.
There are modes read, write, append, and binary mode. Which one do I use? and how?
Like for example:
Filename: Content:
Code:
Jack and Jill
went up the hill
to get a bucket of water
they ran down the hill
and fell together.
so how do I read only
Code:
to get a bucket of water
Do I use? : (This simply prints ALL the texts in Sample.txt)
Code:
FILE *fp;
char ch;
if( (fp = fopen("Sample.txt", "r")) == NULL)
fprintf("stderr, "ERROR: Sample.txt does not exist.\n");
while( (fscanf(fp, "%c", &ch)) == 1)
fprintf(stdout, "%c", ch);
fclose(fp);