Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /*
  2. Arifur Rahman
  3. CS 136
  4. MELISSA LYNCH
  5. LAB 3A
  6. */
  7. #include <iostream>
  8. #include <fstream>
  9. #include <cstdlib>
  10. #include <climits>
  11. #include <string>
  12. using namespace std;
  13. int main(){
  14. ifstream fin("Current_Reservoir_Levels.tsv");
  15. if (fin.fail()) {
  16. cerr << "File cannot be opened for reading." << endl;
  17. exit(1); // exit if failed to open the file
  18. }
  19. string junk; // new string variable
  20. getline(fin, junk); // read one line from the file
  21.  
  22. string userDate;
  23. cin >> userDate;
  24. string date,eastSt,eastEl,westSt,westEl;
  25.  
  26. while(fin >> date >> eastSt >> eastEl >> westSt >> westEl) {
  27. // this loop reads the file line-by-line
  28. // extracting 5 values on each iteration
  29.  
  30. fin.ignore(INT_MAX, '\n'); //skips to the end of line,
  31. //ignorring the remaining columns
  32.  
  33. // for example, to print the date and East basin storage:
  34.  
  35. if (date==userDate){
  36. cout << "East basin storage: "<< eastSt << endl;
  37. }
  38.  
  39. }
  40.  
  41.  
  42. fin.close();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement