trying to save


All right i cleaned my program up a little I'm trying make a database and flowing the directions to write to text file and its not writing don't know why


#include <fstream>
#include <iostream>
#include <string>


using namespace std;

void UserSetup();
void Login();
int Quit();




int main()

{

int choice;

cout << "Welcome to the Tropical Island Game" << endl;
cout << "Login Enter 1" << endl;
cout << "Create New Account Enter 2" << endl;
cout << "Press 3 to Quit" << endl;
cin >> choice;

switch (choice) {

case 1:
Login();
break;
case 2:
UserSetup();
break;
case 3:
Quit();
break;

cin.get();

}
}


// The User password size and domain
std::string getStringOfMinLength(const std::string& prompt, unsigned minLength)
{
std::cout << prompt << '\n' << "(min length = " << minLength << ")\n" ;
std::string str ;
while ( std::cin >> str && str.length() < minLength )
std::cout << "Not long enough! (min length = " << minLength << ")\n" ;

return str;
}
// The User password size and domain

void UserSetup()

{
string password2;
// ofstream to write and txt file
ofstream Users("Users.txt",ios::app);
std::string userName = getStringOfMinLength("Please enter a user ID", 6) ;
repeat2:
std::string password1 = getStringOfMinLength("Please enter a password", 7) ;
cout << "Please RENTER your password\n";
cin >> password2;

if (password1 != password2)
{
cout << "You have ReEnter your password incorrectly \n";
goto repeat2;
}

if (password1 == password2)
{
cout << "You Now registered with Tropical Island\n";
cout << " User name: " << userName << " Password: " << password1 << '\n';
}

// what i need to write to the text file
Users << userName << ' ' << password1 << endl;
Users.close();
main();

system ("pause");
}

void Login()
{
string UserID;
string password;

cout << "Please enter userID\n";
cin >> UserID;
cout << "Pleser enter password\n";
cin >> password;
}

int Quit()
{
return 0;
}
Sorry everyone its working was looking in the directory
Last edited on
Topic archived. No new replies allowed.