Which mode should be passed to open() to add text to the end of an existing file without erasing it?
Correct answer C. 'a'
Explanation
Mode 'a' opens a file for appending, so all writes go to the end and existing content is kept; the file is created if it does not exist. 'w' truncates the file first, 'r' is read-only, and 'x' is for exclusive creation and fails if the file already exists.
Answer checked How we write and check questions
Discussion