-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
39 lines (30 loc) · 840 Bytes
/
test.cpp
File metadata and controls
39 lines (30 loc) · 840 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
35
36
37
38
39
#include <iostream>
#include <string>
#include <limits>
std::string * toMA(std::string& n);
struct User {
std::string name;
short age;
std::string alias;
};
int main() {
User user;
user.age = 0;
std::cout << "Enter your name: ";
std::getline(std::cin, user.name);
std::cout << "Enter your age: ";
std::cin >> user.age;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
if(user.age < 18) {
user.alias = "Kiddo";
} else {
user.alias = "Dummy";
}
std::cout << "Hello, " << user.name << " " << user.alias << "! Welcome to the C++ project. And your name stores at " << toMA(user.name) << "." << std::endl;
std::cout << "Press Enter to continue...";
std::cin.get();
return 0;
}
std::string * toMA(std::string& n) {
return &n;
}