I have written a basic program,and from my understanding(probably completely off),it should open a text file that i have named and saved in the same folder that my program is saved in.
The program will then write the variables i have created to the file and will display them.
Here is my code:
Code:
main()
{
char c = 'J' ;
int i = 5 ;
string s = "Hello" ;
ofstream myfile_out ; // create a file object for output
myfile_out.open("myfile.txt") ; // this will open myfile.txt
//now to write the data to the file
myfile_out << s << ' ' << c << ' ' << i << endl ;
myfile_out.close() ; // close the output file
cout << "Your file contains :" << endl ;
cout << ' ' << myfile.txt << endl ;
}
I also understand that the last line is not correct,but what i am basically trying to do is output the contents of the file.Can someone please explain this to me.



