I have a problem. When I try to load a file into a string array nothing shows.
Firstly I have a file that on one line has a username and on the second has a password.
I haven't finished the code but when I try to display what is in the array nothing displays.
I would love for this to work.
Any suggestions?
users.txt
user1
password
user2
password
user3
password
C++ Code
void loadusers()
{
string t;
string line;
int lineCount=0;
int lineCount2=0;
int lineCount3=0;
ifstream d_file("data/users.txt");
while(getline(d_file, t, '\n'))
++lineCount;
cout << "The number of lines in the file is " << lineCount << endl;
string users[lineCount];
while (lineCount2!=lineCount)
{
getline(d_file,line);
users[lineCount2] = line;
lineCount2++;
}
while (lineCount3!=lineCount)
{
cout << lineCount3 << " " << users[lineCount3] << endl;
lineCount3++;
}
d_file.close();
}