-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringStream.cxx
More file actions
191 lines (157 loc) · 3.23 KB
/
StringStream.cxx
File metadata and controls
191 lines (157 loc) · 3.23 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <iostream>
#include <sstream>
using namespace std;
class cat{
public:
int age;
void meow(){
cout << "meow" << endl;
}
};
//sizeof functionz
int sub1(){
//4 bytes
for(int i=0; i <= 100; i++){
if (i % 3 == 0)
cout << "fizz";
if(i % 5 == 0)
cout << " buzz";
if(i % 3 != 0 && i % 5 !=0)
cout << i;
cout << endl;
}
}
int sub2(){
//4 bytes
return 0;
x}
int sub3(){
//4 bytes
int i = 9;
}
int sub4(){
//4 bytes
int i = 9;
int j = 11;
}
int sub5(){
//4 bytes
int i;
int j;
char c;
}
//adding
int sub6(int array1[]){
//4 bytes
for(int i=0; i < 2; i++)
cout << array1[i] << endl;
}
int stremz(){
string firstname, lastname, userinfo = "donald duck";
istringstream inSS(userinfo);
inSS >> firstname;
inSS >> lastname;
cout << firstname << endl << userinfo;
cout << endl << "Lastname = " << lastname;
inSS.str(""); inSS.clear();
getline(inSS, userinfo);
cout << endl << userinfo;
return 0;
}
void sub7(){
int *ptr;
int size;
cout << "enter size of array \n";
cin>>size;
ptr = new int[size];
for(int i=0; i<size;i++)
cin>>ptr[i];
for(int i=0; i<size;i++)
cout << ptr[i] << endl;
delete[] ptr;
}
void ternOp(){
//ternary operator
int i = 5;
int i2;
cout << "enter a number: ";
cin >> i2;
// if i2 > 5 then i = 7 else i = 69
i = i2 > 5 ? 7 : 69;
cout << endl << i;
//if i2 < 5 --69. between 5&10--7. >10 :4
//true true, true false, false false.
i = i2 > 5 ? i2 < 10 ? 7 : 4 : 69;
cout << endl << i;
}
int main(int argc, char *argv[])
{
//sub7();
stremz();
/* //ends at line 119
struct munster{ //1 byte
};
struct ninja{ //4 bytes
int attack = 7;
};
struct dragon{ //8 bytes
int attack = 70;
int health = 1000;
};
typedef int num;
//num is now a datatype
num h = 3;
//all 4 bytes
int i = 4;
int* ip = &i;
signed int j = 5;
unsigned int k = 6;
bool flag1 = true; //1 byte
short s = 2; //2 bytes
long L = 8; // 8 byted
long long LL = 9; //still 8 bytes
char name[] = "steven";
char char1;
cout << sizeof(name) << endl;
cout << sizeof(char1) << endl;
cout << sizeof(s) << endl;
cout << sizeof(L) << endl;
cout << sizeof(LL) << endl;
cout << sizeof(num) << endl;
cout << sizeof(ip) << endl;
cout << sizeof(flag1) << endl;
//structs
cout << sizeof(munster) << endl;
cout << sizeof(ninja) << endl;
cout << sizeof(dragon) << endl;
//classses: this one 4 bytes
cout << sizeof(cat) << endl;
cat seagull;
seagull.age = 7;
seagull.meow();
//functions, all 4 bytes
cout << sizeof(seagull) << endl;
cout << sizeof(sub1()) << endl;
cout << sizeof(sub2()) << endl;
cout << sizeof(sub3()) << endl;
cout << sizeof(sub4()) << endl;
sub4();
cout << sizeof(sub4()) << endl;
cout << sizeof(sub5()) << endl;
cout << sizeof(sub6()) << endl;
int ifun = sub6();
sizeof(ifun);
*/
//pass array to function
int array1[3] = {3, 2, 1};
sub6(array1);
enum color{
GREEN,
RED,
BLUE,
};
color r = RED;
color b = BLUE;
cout << r;
cout << b;
}