SA is correct.
You may find it better to use
visual-studio-community[
^]. At least take a look at it.
Your code would then work fine because VSC is C++11 compliant.
Passing a std::string to open() is allowed in C++11. You may simply concatenate the two std::strings making your file name using the + operator.
file.open(username + ".txt");
In other compilers you will have to pass a char* (C string). You may use c_str() to get a C string from a std::string after concatenating the two strings.
file.open((filename + ".txt").c_str());