Hello, I am somewhat new to C++ but one thing I can't seem to be able to figure out is how to have users inputed text into a text file using filestreams. I tried signing the users input to a string variable using cin and then putting into the text file. For example:
Can someone explain this to me please?Code:#include <iostream> #include <fstream> using namepace std; int main() { string x; cout << "Enter your name: "; cin >> x; ofstream a_file ("test.txt") a_file << x; return 0; }