0
    void megaadmin()
    {
        system("cls");
        cout<<"this console is only for registering new admins";
        cout<<"please enter the required username";
        string temporary_string;
        cin>>temporary_string;
        ofstream f("admin_details.txt",ios::out|ios::app);
        f<<temporary_string;
        cout<<"please enter the password";
        cin>>temporary_string;
        f<<temporary_string;
        cout<<"would u like to enter more usernames and passwords if yes enter 1 eles 2";
        int n;
        cin>>n;
        if(n==1)
            megaadmin();
        else
            exit(0);
    }

admin_details.txt is getting created but the information that is the username and password that i entering is not getting stored in that particular text file

varun krishna
  • 173
  • 1
  • 2
  • 9

1 Answers1

0

After each cin >> temporary_string; I would add cout << temporary_string for debugging only to make sure that the string is read successfully.

If it is, then there is no output since your stream is probably not flushed. Just call f.flush() and you should see the content.

BTW, when you close the program, the stream will be flushed as well during destruction, so you will see the content as well.

Daniel Trugman
  • 8,186
  • 20
  • 41
  • i dont exactly understand flush but i did flush still it is not working but i recently made another code with some ofstream that is working perfectly fine i dont know why this one is not working – varun krishna Oct 02 '17 at 09:18
  • Check [this](https://stackoverflow.com/questions/14105650/how-does-stdflush-work) out to see what is flushing – Daniel Trugman Oct 02 '17 at 09:19