🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Files and Preprocessor: all 10 questions

Quiz: Files and Preprocessor · Question 7 of 10

What happens when you open an existing file with mode "w"?

What happens when you open an existing file with mode "w"?

  1. A.New data is added at the end
  2. B.Its old contents are erased
  3. C.fopen returns NULL
  4. D.The file is opened read-only
Answer & explanation

Correct answer: Its old contents are erased

"w" creates or truncates; use "a" to keep the contents and append.

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 →