[html]
#include <iostream>
using namespace std;
int main()
{
string str;
cout << "plase enter you name\n";
cin >> str;
cout << "Hello, " << str << "!\n";
}
運行輸出:
[html]
pateo@pateo-B86N53X:~/work/study$ g++ -o hello test.cpp
pateo@pateo-B86N53X:~/work/study$ ls
hello main main.c test.cpp
pateo@pateo-B86N53X:~/work/study$ ./hello
plase enter you name
liaojianguo
Hello, liaojianguo!