How can you open a file for both reading and writing in C?
- fopen("file.txt", "rw")
- fopen("file.txt", "r+")
- fopen("file.txt", "w+")
- open("file.txt", "rw")
The correct option is b. fopen("file.txt", "r+"). This combination of mode flags in the fopen() function allows a file to be opened for both reading and writing, providing flexibility in file manipulation operations.
Loading...
Related Quiz
- In a program that processes large datasets, you notice that reading the data from a file is a performance bottleneck. Which file handling functions could help improve the performance?
- In C, function pointers are useful when you want to choose at runtime which ________ to execute.
- What is the significance of using pointers to functions in C?
- When designing a data packet structure for network communication, using ________ can help to minimize the packet size.
- In a program that manipulates text, you need to store multiple strings. What is a potential issue with using character arrays instead of string literals?