Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+"); ans. Writing Reading Read and Write Appending
Question
Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+");
ans. Writing
Reading
Read and Write
Appending
Solution
The operations that can be performed on the file "NOTES.TXT" using the given code are:
-
Reading: The "r+" mode opens the file for both reading and writing. So, you can read the contents of the file.
-
Writing: As mentioned above, the "r+" mode also allows writing. So, you can modify the contents of the file.
-
Read and Write: Since "r+" mode allows both reading and writing, you can perform both operations on the file.
-
Appending: No, you cannot append to the file using "r+". For appending, you would need to open the file in "a" or "a+" mode. In "r+" mode, if you write to the file, it will overwrite the existing contents, not append to them.
Similar Questions
Which of the following mode of fopen() function opens a file only for writing. If a file with that name does not exist, attempts to create a new file. If the file exist, place the file pointer at the end of the file after all other data.Select one:a.Wb.Wc.Ad.A+
What will the following code snippet do?with open("example.txt", "a") as file: file.write("Hello, World!")
What do the following lines of code do?with open("Example1.txt","r") as file1: FileContent=file1.read() print(FileContent)
In C language, which of the following functions are applied to write data to a file?Select one:a.fputs, puts, fprintf, fscanfb.None of the others.c.fgetchar, fputchar, freadchard.fprintf, fputc, fputs
What is the purpose of "rb" in fopen() function used below in the code? FILE *fp; fp = fopen("source.txt", "rb"); ans. open "source.txt" in binary mode for reading Create a new file "source.txt" for reading and writing open "source.txt" in binary mode for reading and writing None of above
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.