Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. /**
  2. * @file Main.cpp
  3.  
  4. * This my project, which takes user input and analyzes the given files
  5. * to find the maximum, minimum, and requested numbers in the file.
  6. *
  7. * @author Griffin Homan (griffh)
  8. * @date   April 13th, 2015
  9. *
  10. * Virginia Tech Honor Code Pledge
  11. * On my honor:
  12. *
  13. * - I have not discussed the C++ language code in my program with
  14. * anyone other than my instructor or the teaching assistants
  15. * assigned to this course.
  16. * - I have not used C++ language code obtained from another student,
  17. * or any other unauthorized source, either modified or unmodified.
  18. * - If any C++ language code or documentation used in my program
  19. * was obtained from another source, such as a text book of coarse
  20. * notes, that has been clearly noted with a proper citation in
  21. * the comments of my program.
  22. * - I have not designed this program in such a way as to defeat or
  23. * interfere with the normal operation of the Web-Cat Server.
  24. *
  25. * Griffin Homan
  26. */
  27.  
  28. #include <iostream> //calls the information needed
  29. #include <fstream>
  30. #include <string>
  31.  
  32. using namespace std; //sets all unmarked commands to std::
  33.  
  34. struct Student
  35. {
  36.     string firstName;
  37.     string lastName;
  38.     string id;
  39.     double gpa;
  40. };
  41.  
  42. int readArray(ifstream& ifile, Student arr[]);
  43.  
  44. int main()
  45. { // Declares the needed variables
  46.     double i, min, max;
  47.     string filename;
  48.     ifstream ifile;
  49.     Student arr[1000];
  50.  
  51.     cout << "Input File Name: ";//requesting the file name
  52.     cin >> filename;
  53.  
  54.     ifile.open(filename.c_str());//opening the file
  55.  
  56.     if (!ifile)//checking if it opened or not
  57.     {
  58.         cout << endl << "That file does not exist!" << endl;//informing the user it did
  59.         //not open and returning 1
  60.     }
  61.  
  62.     cout << "Which number do you want to return? ";//requesting the desired number
  63.     cin >> i;
  64.  
  65.     readArray(ifile, arr);
  66.  
  67.     return 0;
  68. }
  69.  
  70. int readArray(ifstream& ifile, Student arr[])
  71. {
  72.     int counter = 0;
  73.     int num;
  74.  
  75.     ifile >> arr[1];
  76.  
  77.     while (ifile)
  78.     {
  79.         ifile >> num;
  80.     }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement