-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBai44.cpp
More file actions
106 lines (84 loc) · 1.74 KB
/
Bai44.cpp
File metadata and controls
106 lines (84 loc) · 1.74 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
/*
Struct và con trỏ
*/
#include <iostream>
using namespace std;
struct Car {
char owner[100];
char brand[100];
char color[100];
int weight;
int height;
int width;
};
struct Cat {
char name[100];
int age;
float weight;
char color[100];
char eyesColor[100];
};
struct Student {
char ID[20];
char name[100];
int age;
float mark;
char address[100];
Car car;
Cat pet;
};
void getInfo(Student& s) {
cout << "Enter name: ";
cin.getline(s.name, 99);
cout << "Enter age: ";
cin >> s.age;
cout << "Enter address: ";
cin.ignore();
cin.getline(s.address, 99);
cout << "Enter mark: ";
cin >> s.mark;
cin.ignore();
cout << "Car color: ";
cin >> s.car.color;
}
void getInfo2(Student* s) {
cout << "Enter name: ";
cin.getline(s->name, 99);
cout << "Enter age: ";
cin >> s->age;
cout << "Enter address: ";
cin.ignore();
cin.getline(s->address, 99);
cout << "Enter mark: ";
cin >> s->mark;
cin.ignore();
cout << "Car color: ";
cin >> s->car.color;
}
void showInfo(Student s) {
cout << "========== Student Info ==========\n";
cout << "Name: " << s.name << endl;
cout << "Address: " << s.address << endl;
cout << "Age: " << s.age << endl;
cout << "Mark: " << s.mark << endl;
cout << "Car color: " << s.car.color << endl;
cout << "==================================\n";
}
void showInfo2(Student *s) {
cout << "========== Student Info ==========\n";
cout << "Name: " << (*s).name << endl;
cout << "Address: " << (*s).address << endl;
cout << "Age: " << (*s).age << endl;
cout << "Mark: " << (*s).mark << endl;
cout << "Car color: " << (*s).car.color << endl;
cout << "==================================\n";
}
int main() {
Student s;
Student* sPtr;
getInfo(s);
sPtr = &s;
showInfo2(sPtr);
//delete sPtr;
return 0;
}