I've just learned how to use write to files and output whats in them off of this site's tutorial and was wondering how to output the whole string of characters into the console window:
This program only outputs "this".Code:#include <fstream> #include <iostream> using namespace std; int main() { char str[10]; /*creates an instance of ofstream and opens example.txt*/ ofstream a_file ( "example.txt" ); /*outputs to example.txt through a_file*/ a_file << "This is my first program using files!!!"; /*close the file stream explicitly*/ a_file.close(); /*opens the file for reading*/ ifstream b_file ( "example.txt" ); /*reads the string from the file*/ b_file >> str; /*should print this*/ cout << str << endl; cin.get(); }
Thanks for the help in advance!