Hello! Next problem: C ++ cannot open the file. Tried both an absolute and relative path, and a Visual Studio and Clion. The operating system is Windows 10. Could it be a problem that there is no access to this file? (In Python, files normally open and read) Here is the code:

fstream f; f.open("in.txt", ios::in); cout << f.is_open(); 

Actually f.is_open () returns 0. The file is in the correct directory. Thank you in advance!

  • Read the documentation for the function used. - nick_n_a
  • one
    Something tells me that the file is not in the directory. Write the path type "C: \\\\ in.txt" and check. And don't forget that in order to write a backslash in C ++ - you need to write it twice (google, why it is so) - Mishakov Maxim
  • Clion earned, VS refuses - a.rahmanovsky

1 answer 1

You are not using the function correctly.

 fstream f; f.open("in.txt", ios::in); f << ..информация для записи..;