P

Priyanka Tomar • 35.28K Points
Coach

Q. Which of the following is the correct syntax to open a file in C++?

  • (A) ofstream file('filename.txt');
  • (B) ofstream file("filename.txt");
  • (C) ifstream file('filename.txt');
  • (D) ifstream file("filename.txt");
  • Correct Answer - Option(B)
  • Views: 47
  • Filed under category C++

Explanation by: Priyanka Tomar
In C++, to open a file for writing, use 'ofstream file("filename.txt");'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics