Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream inFile;
- inFile.open("userData.txt");
- // Check for error
- if (inFile.fail()) {
- cerr << "error opening file" << endl;
- exit(1);
- }
- string user, pass;
- int Count = 0;
- // Read file till you reach the end and check for matchs
- while (!inFile.eof()) {
- inFile >> user >> pass;
- if (user == "Banana", "Apple") {
- Count++;
- }
- cout << Count << " users found!" << endl;
- }
- }
- while (!inFile.eof()) {
- inFile >> user >> pass;
- if (user == "Banana", "Apple") {
- Count++; //no point in doing so because this only happens once
- }
- cout << Count << " users found!" << endl;
- }
- while (!inFile.eof()) {
- inFile >> user >> pass;
- if (user == "Banana", "Apple") {
- Count++; //no point in doing so because this only happens once
- }
- cout << Count << " users found!" << endl;
- }
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream inFile;
- inFile.open("userData.txt");
- //Check For error
- if (inFile.fail()) {
- cerr << "error opening file" << endl;
- exit(1);
- }
- string user, pass;
- int Count = 0;
- //read file till you reach the end and check for matchs
- while (inFile >> user >> pass) {
- if (user == "Banana" && pass == "Apple") {
- cout <<"user found!" << endl;
- }
- }
- }
Add Comment
Please, Sign In to add comment