[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem 6



 > From: Flora  <http://www.gmail.com/~flora>
 > Date: Thu, 22 Jun 2017 19:12:56 -0400
 >
 >  I'm currently working on lines 109-125. I'm trying to get it to read and
 >  verify username and password in creds.txt.
 >  I'm going to call this function in the int main() on line 151.
 >  Thanks!
 > 
 > // function to verify user and log in
 > bool checkCreds (string username, string encrypted)
 > {
 > 
 > int i;
 > string username;
 > string encrypted;
 > ifstream inFile;
 > string inputFileName, inFileData;
 > inFile.open(inputFileName.c_str());
 > getline(inFile, inFileData);
 > inFile.close();
 > if (username == inFileData.substr (0, (i=(inFileData.find(':'))-1)))

I would separate out the setting of 'i' before the 'if', rather than
embedding the assignment in the call.

Also, I'm assuming that you'll need to call getline() for every line in
the file?  In which case, it will need to be in a loop.  (It looks like
getline() returns false upon end-of-file.)

I think what you're doing is the right approach.  Just need to go further.

 >  }




Why do you want this page removed?