Guest User

Untitled

a guest
Jan 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. //Define functions.
  7. void input(ifstream& fin, char& fileName);
  8.  
  9. int main()
  10. {
  11. ifstream fin;
  12. char fileName[20];
  13. input(fin, fileName);
  14. return 0;
  15. }
  16.  
  17. void input(ifstream& fin, char& fileName)
  18. {
  19. cout << "Input file name: ";
  20. cin >> fileName;
  21. fin.open(fileName);
  22.  
  23. if(fin.fail())
  24. {
  25. cout << "The file: " << fileName << " does not open." << endl;
  26. exit(1);
  27. }
  28. //return;
  29. }
  30.  
  31. #include <iostream>
  32. #include <fstream>
  33. #include <cstdlib>
  34. using namespace std;
  35.  
  36. //Define functions.
  37. void input(ifstream& fin, string& fileName);
  38.  
  39. int main()
  40. {
  41. ifstream fin;
  42. string fileName;
  43. input(fin, fileName);
  44. return 0;
  45. }
  46.  
  47. void input(ifstream& fin, string& fileName)
  48. {
  49. cout << "Input file name: ";
  50. cin >> fileName;
  51. fin.open(fileName.c_str());
  52.  
  53. if(fin.fail())
  54. {
  55. cout << "The file: " << fileName << " does not open." << endl;
  56. exit(1);
  57. }
  58. //return;
  59. }
  60.  
  61. void input(ifstream *fin, char *fileName);
  62.  
  63. input(&fin, &fileName); // call
Add Comment
Please, Sign In to add comment