I am writing a program in C++ that is supposed to store user informations inside of a file (The os is Windows 10).
Here is the function:
void new_user()
{
std::string user_name, user_surname, user_username, user_password;
std::cout << "Name: "; std::cin >> user_name;
std::cout << "\nSurname: "; std::cin >> user_surname;
std::cout << "\nUsername: "; std::cin >> user_username;
std::ofstream FileInfo = create_file(user_username + ".txt");
FileInfo.close();
}
And this is the create_file()
function:
std::ofstream create_file(const std::string & Path)
{
std::ofstream File(Path, std::ios::out | std::ios::app | std::ios::binary);
File.close();
return File;
}
I am trying to store the file into a folder like that:
std::ofstream FileInfo = create_file("/Users/ " + user_username + ".txt"); // here is what I have tried
However, what I have tried does not work properly, in fact it does not create any file or folder.
What should be the solution?
Aucun commentaire:
Enregistrer un commentaire