-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.cpp
More file actions
28 lines (19 loc) · 784 Bytes
/
Copy pathinput.cpp
File metadata and controls
28 lines (19 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int main () {
//user input
int x;
cout << "enter a number ";
cin >> x;
cout << "you entered " << x; //space is terminator hence sam max will output sam only in string and in int it will return single first no. before sapce
string y ;
cout << "ENTER YOUR NAME :";
cin >> y ;
cout << "YOUR NAME IS :" << y;
// as above space act as terminator .That's why, when working with strings, we often use the getline() function to read a line of text. It takes cin as the first parameter, and the string variable as second:
//getline() function
string z; //works stand alone
cout << "ENTER YOUR NAME : ";
getline(cin,z);
cout << "YOUR NAME IS : " << z ;
}