WorksheetsC Programming Day-13
Total questions: 10
Worksheet time: 3mins
What does this declaration mean?
Creates a new file
Declares a file pointer
Opens a file for writing
Closes the file
Which function is used to open a file in C?
open()
file()
fopen()
start()
Which mode opens a file for writing and overwrites existing content?
"r"
"a"
"r+"
"w"
What does "a+" mode do?
Opens file for reading and appending
Deletes the content of file
Opens file for writing and reading
Opens file for appending only
Which function is used to write a string to a file?
fputs()
fprintf()
fputc()
fwrite()
What happens if the file you try to open in "r" mode doesn’t exist?
It creates an empty file
It returns NULL
It gives a warning
It creates the file
What is the purpose of fclose(fp);?
To close the file
To free memory
To flush the buffer
All of the above
Which function reads a single character from the file?
getch()
fgetc()
getchar()
getc()
How can you check if the file opened successfully?
fp == 1
fp == EOF
fp == NULL
fp == 0
Which mode creates a new file if it doesn’t exist and appends to the end if it does?
"a"
"r+"
"w"
"r"
