I need to enter only the name of a user and automatically put ".txt" in the end of the name to create a text archive without the need of the user to write the ".txt" in the end;
something like that:
1 2 3 4
string name;
cin >> name;
ofstream user(name.c_str());//but add the .txt in the end
What have you tried? You're using a std::string so you can just "add" the desired extension to the end of the string.
By the way if you are compiling for one of the current C++ standards (C++11, C++14) you shouldn't need to use c_str() any longer for the stream constructors.