Thank you very much, it works. Although, the real reason for this line was to do an ofstream to write in to file. Now when I do ofstream(GetConvertedFileName(GetNewFileNumber())); it gives me errors again (Im sure that the string a=... was right though as you said). The error I get is: no matching function for call to `std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(std::string)'
EDIT: I made a big mistake, forgot how ofstream works. anyways, this is what I tried next:
1 2 3 4 5
ofstream(userfile);
userfile.open(GetConvertedFileName(GetNewFileNumber()));
Errors:
no matching function for call to `std::basic_ofstream<char, std::char_traits<char> >::open(std::string)'
Ok now, I have been trying some new ways and I found a way to make it work.
1 2 3 4
string a=GetConvertedFileName(GetNewFileNumber());
constchar * c = a.c_str();
ofstream(userfile);
userfile.open(c);
You said you dont understand what im doing. To explain, im creating a database with users. This current lines I was asking for were being executed when a user is creating a new contact. It will create something like 6.txt (according to how many accounts were created already(from 0 to 100)).
Now, I can't understand one thing.
This works when its in the int main(), but doesnt when its in a void: