Basic Practice Problems based on chapter which you learn in previous Tutorials.
The
fopen
function is used to open a file named "
example.txt
" in write mode ("w").
If the file is successfully opened, the program writes the sentence to the file using
fprintf
.
Finally, the fclose function is used to close the file.
The
fopen
function is used to open the file named
"example.txt"
in read mode ("r").
If the file is successfully opened, the program uses
fgets
to read the first line from the file into the line buffer and if the file is empty, a message indicating that the file is empty is printed and the
fclose
function is used to close the file.
Was this helpful?