Guest User

Untitled

a guest
Feb 18th, 2019
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. while (!inFile.eof()) {
  2. inFile >> user >> pass;
  3. if (user == "Banana", "Apple") {
  4. Count++; //no point in doing so because this only happens once
  5. }
  6. cout << Count << " users found!" << endl;
  7. }
  8.  
  9. #include <iostream>
  10. #include <fstream>
  11. #include <string>
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17. ifstream inFile;
  18. inFile.open("userData.txt");
  19.  
  20. //Check For error
  21. if (inFile.fail()) {
  22. cerr << "error opening file" << endl;
  23. exit(1);
  24. }
  25.  
  26. string user, pass;
  27. int Count = 0;
  28.  
  29. //read file till you reach the end and check for matchs
  30. while (inFile >> user >> pass) {
  31. if (user == "Banana" && pass == "Apple") {
  32. cout <<"user found!" << endl;
  33. }
  34. }
  35. }
Add Comment
Please, Sign In to add comment