I'm trying to make a program that will get the user input of a new file name, create the file, and write to it. It works but it will only write the first word of the string to the file. How can i get it to write the full string? thanks.
#include "stdafx.h" #include <fstream> #include <iostream> #include <string> using namespace std; int main() { for (;;) { char *myFile = " "; string f = " "; string w = " "; cout <<"What is the name of the file you would like to write to? " <<endl; cin >>f; ofstream myStream(f,ios_base::ate|ios_base::out); cout <<"What would you like to write to " <<f <<" ? "; cin >>w; myStream <<w; if (myStream.bad()) { myStream <<"A serious error has occured."; myStream.close(); break; } } }