When I run this program I enter the file data I wish to put in the created file, say for example " Hello File Data" and when I look into that file once its been created there is only the first word ("Hello") in the case of this example. Here is the code:
The main function:
[source lang="cpp"] cout << "Enter the file name: " << endl; cin >> filename; outFile.open(filename.c_str());//create the file if (!outFile) { //file could not be created cout<< "File could not be completed" << endl; break; } else // file was created cout << "FILE WAS COMPLETED NAMED: " << filename << endl;; //ask the user to put some data y/n cout << "Would you like to set some initial data in the file? y/n" << endl; cin >> choice; switch(choice) { case 'y': cout << "Enter the data: " << endl; cin >> filedata; user1.createFile(outFile, filedata); break; case 'n': cout << "Ok then dont create initial data... Your created file is blank" << endl; break; } [/source]
The create filefunction:
[source lang="cpp"]void User::createFile(ofstream &outfile, string filedata){ //output the file into outfile outfile << filedata; cout << "You have successfully saved the data you entered" << endl;}[/source]
Please help!
Thanks
I will attach the zip folder as well just in case...

Find content
Male