Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Arifur Rahman
- CS 136
- MELISSA LYNCH
- LAB 3A
- */
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <climits>
- #include <string>
- using namespace std;
- int main(){
- ifstream fin("Current_Reservoir_Levels.tsv");
- if (fin.fail()) {
- cerr << "File cannot be opened for reading." << endl;
- exit(1); // exit if failed to open the file
- }
- string junk; // new string variable
- getline(fin, junk); // read one line from the file
- string userDate;
- cin >> userDate;
- string date,eastSt,eastEl,westSt,westEl;
- while(fin >> date >> eastSt >> eastEl >> westSt >> westEl) {
- // this loop reads the file line-by-line
- // extracting 5 values on each iteration
- fin.ignore(INT_MAX, '\n'); //skips to the end of line,
- //ignorring the remaining columns
- // for example, to print the date and East basin storage:
- if (date==userDate){
- cout << "East basin storage: "<< eastSt << endl;
- }
- }
- fin.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement