Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. void Shop::Add_Customer()
  2. {
  3. fstream myfile; myfile.open("CustomerFile.txt");
  4. string name, password, phonenbr;
  5. string buffer, delimitor = "::";
  6.  
  7. system("cls");
  8. cout << "Name of the customer: "; cin >> name;
  9. cout << "Password of the customer: "; cin >> password;
  10. cout << "Phone number of the customer: "; cin >> phonenbr;
  11.  
  12. if (!myfile.is_open())
  13. {
  14. myfile.open("CustomerFile.txt", ios::out);
  15. }
  16. //myfile << name + delimitor + password + delimitor + phonenbr << endl;
  17.  
  18. if (myfile.peek() == std::ifstream::traits_type::eof())
  19. {
  20. myfile << name + delimitor + password + delimitor + phonenbr << endl;
  21. }
  22. else
  23. {
  24. while (getline(myfile, buffer))
  25. {
  26. if (CheckIfCustomerExist(buffer, name, phonenbr) == true)
  27. {
  28. cout << "Customer already exist" << endl;
  29. }
  30. else
  31. {
  32. myfile << name + delimitor + password + delimitor + phonenbr << endl;
  33. cout << "Customer insert in the file " << endl;
  34. }
  35. }
  36. }
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement