blob: c55ee7cc16b69dfb5fafd6a96294071194a5e488 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
CST 116 Austin Guertin
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
11c
|