Print all usernames after registering with txt

this is my code, the program has to ask for the number of usernames I want to create, then you type the username and password. after you do it 4 times (maximum) it prints (better if you help me to make a button to print the list) the username and password of each

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
    int n;
    string username;
    string password;

    ofstream myfile;
    myfile.open ("tareaf.txt");

    cout << "How many usernames yo uwant to register?" << endl << endl;
    cin>>n;

    if(myfile.is_open())
    {
        for(int a=0,a<4,a++)
         cout << "Create your username: ";

         getline(cin, username);

         myfile << username;

cout << "Create your password: ";
         getline(cin, password);

         myfile << password;

         myfile.close();
     }

    return 0;
}


line 21: expected initializer before '<' token
expected ',' before '<' token
expected primary expression before '<' token

also, if you can help me mask the password with "*" thank you very much
Last edited on
For loops need to have semicolons instead of comas. As for password masking, that's not in the domain of standard C++. You'll need an external library for that.

-Albatross
Last edited on
Topic archived. No new replies allowed.