I am creating a somewhat weak/vague database (My experience is very little, and please forgive the mess of my code). For this, I create a check everytime my console program starts that checks whether a database (copied to userlist.txt) is created already, if not a new will be created, if the database exists, however, it should all be copied to a 'vector users' (Which is a struct) I have within the class 'userbase' that will then contain all user information.
My userstats struct looks like this,
enum securityLevel {user, moderator, admin};
struct userstats
{
    string ID;
    string name;
    string password;
    securityLevel secLev;                         
};
I will contain all this information from a textfile in this code,
    int main()
    {
        Userbase userbase;  // Class to contain userinformation during runtime.
        ifstream inFile;
        inFile.open("userlist.txt");
        if(inFile.good())
        {
            // ADD DATE OF MODIFICATION
            cout << "USERLIST FOUND, READING USERS.\n";
            userstats tempBuffer;
            int userCount = -1;
            int overCount = 0;
            while(!inFile.eof())
            {
                string buffer;
                getline(inFile, buffer);
                if (buffer == "ID:")
                {
                    userCount++;
                    if (userCount > overCount)
                    {
                        userbase.users.push_back(tempBuffer);
                        overCount++;
                    }
                    tempBuffer.ID = buffer;
                    cout << "ID";           // Just to see if works
                }
                else if (buffer == "name:")
                {
                    cout << "name";         // Just to see if works
                    tempBuffer.name = buffer;
                }
                else if (buffer == "password:")
                {
                    cout << "password";     // Just to see if works
                    tempBuffer.password = buffer;
                }
            }
            if (userCount == 0)
            {
                userbase.users.push_back(tempBuffer);
            }
            inFile.close();
        }
...
What I try to do is to read and analyze every line of the text file. An example of the userlist.txt could be,
created: Sun Apr 15 22:19:44 2012
mod_date: Sun Apr 15 22:19:44 2012
ID:1d
name:admin
password:Admin1
security level:2
(I am aware I do not read "security level" into the program yet)
EDIT: There could also be more users simply following the "security level:x"-line of the preceding user in the list.
Now, if the program reads the line "ID:1d" it should then copy this into the struct and finally I will put it all into the vector userbase.users[i]. This does not seem to work, however. It does not seem to catch on to any of the if-statements. I've gotten this sort of program to work before, so I am very confused what I am doing wrong. I could really use some help with this. Any other kind of criticism of the code is very welcome.
Regards, Mikkel
 
     
    