So i have problem with files. Idea is to open files with different names using one function, and write some data to them, also want them to have file extensions:
void openFile (filename, somedata) {
ofstream file;
file.open(filename + ".txt"); // .txt for example, any other is OK
file << somedata;
file.close();
}
The result should be that we have many files created automatically like "John.marks, Clara.marks" or "usa.cities, russia.cities".
Is there something i am doing wrong, 'cause it worked before.
Also here is the error message i am getting
[Error] no matching function for call to 'std::basic_ofstream<char>::open(std::basic_string<char>, const openmode&)'
It compiles perfectly OK on cpp.sh (click the "edit and run" button next to your code sample). (Minor warning that bool login() doesn't return anything yet, but that's not your issue.)
If I run it on my PC, and type "register" (you could do with a better prompt) then I can enter username and password and it creates the appropriate file. (I won't comment on whether single files for each user is actually a good idea or not.)
So your error message doesn't correspond to your posted code. You've got your versions muddled up, perhaps?
Possibly you aren't compiling using the latest c++ version? Originally .open() didn't support a std::string type as a file name and you had to use a c-str type. This was fixed in version xxx (I forget which). As the error message refers to .open(), this could be the issue.