Guest User

Untitled

a guest
Jun 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. cout << "Please input the file to select first name from" << endl;
  2. char* filename1 = new char[80];//for name of file
  3. cin.ignore();//ignores past cin
  4. cin.getline(filename1, 80);//takes in the name
  5. char ** file1 = new char*[5];
  6.  
  7. ifstream newFile1; //new file
  8. newFile1.open(filename1);//opens file with the name put in
  9. if (!newFile1) {//if file doesn't exist
  10. cout << "There was an error reading the file" << endl;
  11. }
  12. else {
  13. int i = 0;
  14. while (newFile1.eof() != -1) {//while not end of file
  15. newFile1.getline(file1[i], 80, ',');//gets line splitting over comma
  16. i++;
  17. }
  18. }
  19. newFile1.close();
  20. //newFile1.clear();
  21.  
  22. char** file2 = new char*[5];
  23. cout << "Please input the file to select second name from" << endl;
  24. char* filename2 = new char[80];//for name of file
  25. cin.ignore();//ignores past cin
  26. cin.getline(filename2, 80);//takes in the name
  27.  
  28. //ifstream newFile2; //new file
  29. newFile1.open(filename2);//opens file with the name put in
  30. if (!newFile1) {//if file doesn't exist
  31. cout << "There was an error reading the file" << endl;
  32. }
  33. else {
  34. int i = 0;
  35. while (newFile1.eof() != -1) {//while not end of file
  36. newFile1.getline(file2[i], 80, ',');//gets line splitting over comma
  37. i++;
  38. }
  39. }
  40. newFile1.close();
  41. //newFile1.clear();
Add Comment
Please, Sign In to add comment