Skip to content

Commit 20f10c1

Browse files
committed
userinput: user input string
get the name of the user and print it out
1 parent f546caf commit 20f10c1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

userinput/userinputstring.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* learn to get user input
3+
*/
4+
5+
#include <iostream>
6+
#include <string>
7+
8+
int main()
9+
{
10+
// you can store upto 20 names
11+
std::string names[20];
12+
13+
std::cout<<"Enter Your First Name :";
14+
std::cin>>names[0];
15+
16+
std::cout<<"Enter Your Second Name :";
17+
std::cin>>names[1];
18+
19+
std::cout << names[0] << " " << names[1];
20+
return 0;
21+
}

0 commit comments

Comments
 (0)