diff options
| -rw-r--r-- | CST116F2021-Lab8/CST116F2021-Lab8.cpp | 76 |
1 files changed, 73 insertions, 3 deletions
diff --git a/CST116F2021-Lab8/CST116F2021-Lab8.cpp b/CST116F2021-Lab8/CST116F2021-Lab8.cpp index 0856b95..2bf5681 100644 --- a/CST116F2021-Lab8/CST116F2021-Lab8.cpp +++ b/CST116F2021-Lab8/CST116F2021-Lab8.cpp @@ -1,11 +1,81 @@ CST 116 Austin Guertin -13a 11.7 pg 317 #5-6 statements for 5, judgements for 6 +13a 11.7 pg 317 #5-6 (Statements for 5, Judgements for 6) + 5) + .cpp -13b 11.9 pg 323 #1 write a full program to call the function +#include <fstream> +#include <iostream> +#include <string> + +using namespace std; +const int RECORDS = 100; +const int MAX = 4; + +int main() +{ + string records[RECORDS]; + int num_records = 0; + + //Open the file + ifstream inFile; + ofstream outFile; + inFile.open("C:\\TEMP\\13a_number5_data.txt"); + outFile.open("C:\\TEMP\\13a_number5_report.txt"); + + //Check to see if file is open (a) + if (inFile.is_open() && outFile.is_open()) + { + cout << "\n\n"; + + // Read until end of file is reached + while (!inFile.eof()) + { + //Priming read (b) + getline(inFile, records[num_records], ' '); + cout << records[num_records]; + outFile << records[num_records]; + + num_records++; + } + cout << "\n\n\n\n"; + + //close the file (c) + inFile.close(); + } + else + { + cout << "ERROR: This file could not be opened for some reason\n\n"; + return num_records; + } +} + +13a_number5_data - Notepad + +lname1, id1, age +lname2, id2, age +lname3, id3, age +lname4, id4, age +lname5, id5, age +lname6, id6, age + +13a_number5_report - Notepad + +lname1,id1,age +lname2,id2,age +lname3,id3,age +lname4,id4,age +lname5,id5,age +lname6,id6,age + + 6) + + a. False + +13b 11.9 pg 323 #1 (Write a full program to call the function) @@ -13,5 +83,5 @@ CST 116 Austin Guertin -11.14 pg 226-337 #1 +11.14 pg 336-337 #1 |