Q. Which of the following is the correct syntax to open a file in C++?
β
Correct Answer: (B)
ofstream file("filename.txt");
Explanation: In C++, to open a file for writing, use 'ofstream file("filename.txt");'.