← Quiz: Files and Preprocessor: all 10 questions
Quiz: Files and Preprocessor · Question 8 of 10
Which function reads a whole line of text, including spaces, from a file?
Which function reads a whole line of text, including spaces, from a file?
- A.fscanf(fp, "%s", buf)
- B.fgets(buf, size, fp)
- C.fputc(c, fp)
- D.fprintf(fp, "%s", buf)
Answer & explanation
Correct answer: fgets(buf, size, fp)
fscanf with %s stops at a space; fgets reads up to the newline or size - 1 characters.
Can you get the rest right without peeking?
Take the timed Quiz: Files and Preprocessor quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →