-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
34 lines (29 loc) · 716 Bytes
/
test.cpp
File metadata and controls
34 lines (29 loc) · 716 Bytes
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
#include <iostream>
using namespace std;
typedef struct {
int num1;
float num2;
string str1;
} struct1;
struct1 globalStruct;
void changeStruct() {
globalStruct.num1 = 100;
globalStruct.num2 = 100.1010;
globalStruct.str1 = "Global struct";
}
void printStruct() {
cout << "num1 = " << globalStruct.num1 << endl;
cout << "num2 = " << globalStruct.num2 << endl;
cout << "str1 = " << globalStruct.str1 << endl;
}
int main() {
// printf("Hello world from printf");
// cout << "Hello world from cout";
globalStruct.num1 = 1;
globalStruct.num2 = -1.1;
globalStruct.str1 = "Local struct";
printStruct();
changeStruct();
printStruct();
return 0;
}