It looks like there's a '\n' left in the input buffer...
Discarding it with std::cin.ignore() seems to solve the problem.
You could consider using std::string as a type for this variable too, as well as you do later: it should solve the issue automatically.
First understand that "cin >>" is formatted input. That is there is some type checking based on the type of variable that "cin" is putting information into. This can be useful when your input is to a numeric variable and something other than a number is entered. Also note that "cin" will input to the first white space or "\n" (new line) that is encountered. So when "cin" reads from the keyboard or a file it will take everything except the "\n" which it leaves in the input buffer. Another "cin >>" will ignore the "\n" and read the next piece of information.
The problem occurs when a "std::getline()" follows a "cin >>". The "cin" leaves the "\n" in the input buffer, but "std::getline()" will extract the "\n" from the input buffer and continue on working with an empty string.
This is where the "cin.ignore()" comes in to clear the input buffer before a "std::getline()" can be used.
Now "cin.ignore()" does work, but the more preferred way is to include the header file "limits" and use std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');. This code can also be used as a way to pause the program and keep the console window open.
Your program does include the header file "string". I would suggest using "std::string" in place of the C-style char array. Since C++ 11 a "std::string" can be used to open a file.
On line 18 you open a file even though the file will close when the program ends it is good practice to close the file when you are finished using it.
Regarding the compiler error with string versus character array, most likely you are using an older compiler or it is not configured to use the latest C++ standard.
When using std::string namefile you may need to try this:
Current standard:
std::ofstream output_oper(namefile);
Older version of C++:
std::ofstream output_oper(namefile.c_str());
Generally you should prefer to use std::string as it is safer than using a character array.
Also, it's a good idea to update the compiler, or configure it to use at least C++11 or later.