Basic usage of getting data from standard input (keyboard normally) using std::cin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<string> | |
int main() | |
{ | |
std::string name; | |
std::cout << "Please enter your name : "; | |
std::cin >> name; | |
std::cout << "Hello " << name << std::endl; | |
return 0; | |
} |
To build:
$: clang++ getinput.cpp
Run it:
$: ./a.out
No comments:
Post a Comment