diff options
| author | austinsworld15 <[email protected]> | 2021-11-15 16:03:48 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-15 16:03:48 -0800 |
| commit | 77098d9477c68b4db2f2f60a3e74f0a2dded1fc4 (patch) | |
| tree | 4e0fbedb875be80ae1f4d212a5ee95b5de6fa864 /CST116F2021-Lab7/CST116F2021-Lab7.cpp | |
| parent | Update CST116F2021-Lab7.cpp (diff) | |
| download | cst116-lab7-austinsworld15-77098d9477c68b4db2f2f60a3e74f0a2dded1fc4.tar.xz cst116-lab7-austinsworld15-77098d9477c68b4db2f2f60a3e74f0a2dded1fc4.zip | |
Update CST116F2021-Lab7.cpp
Diffstat (limited to 'CST116F2021-Lab7/CST116F2021-Lab7.cpp')
| -rw-r--r-- | CST116F2021-Lab7/CST116F2021-Lab7.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/CST116F2021-Lab7/CST116F2021-Lab7.cpp b/CST116F2021-Lab7/CST116F2021-Lab7.cpp index ae872cd..c55ee7c 100644 --- a/CST116F2021-Lab7/CST116F2021-Lab7.cpp +++ b/CST116F2021-Lab7/CST116F2021-Lab7.cpp @@ -3,7 +3,63 @@ Module 7: Lab 7 12a - + #include <iostream> +#include <string> + +using namespace std; + +//function to read input +void read(string str[], int idx) +{ + getline(cin, str[idx]); +} + +int main() +{ + + string str[100]; + int choice, size = 0; + + + while (1) + { + + cout << "\nPress 1: To add a string\n"; + cout << "Press 2: To print the strings\n"; + cout << "Press 3: Exit the program\n\n"; + cout << "Enter your choice down below: "; + cin >> choice; + + + if (choice == 1) + { + cin.ignore(80, '\n'); + cout << "\nEnter a string: "; + read(str, size++); + } + + + else if (choice == 2) + break; + + + else if (choice == 3) + return 0; + else + cout << "\n\nInvalid input!\n\n"; + } + + + cout << endl << "The input strings are: \n\n"; + for (int i = 0; i < size; i++) + { + if (str[i] == "don't print") + break; + cout << str[i] << endl; + } + + return 0; +} 12b |