0

How to open data files

c++

17th Jan 2017, 10:39 PM
Lacey Harris
Lacey Harris - avatar
3 Answers
+ 6
#include <iostream> #include <fstream> using namespace std; int main () { string str; ifstream me_tryna_read_file; me_tryna_read_file.open("file.txt"); me_tryna_read_file >> str; me_tryna_read_file.close(); cout << str; return 0; } // reads one string from dem text file.
18th Jan 2017, 2:39 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
In c++ I think you can use #include<fstream> with key words in the code : ifstream and ofstream (to read or write in .txt or binary files
17th Jan 2017, 11:22 PM
Amir Zahirovic
Amir Zahirovic - avatar
+ 1
yes you are correct c++ can write to and read from a text file. Sololearn does not go into it in great detail. go to the websites 'tutorialspoint' or 'cplusplus' for a more detailed explaination.
18th Jan 2017, 12:35 AM
Jason Hoffman
Jason Hoffman - avatar