📜  C++ 键盘输入 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:50.631000             🧑  作者: Mango

代码示例1
#include   // for std::cout and std::cin
 
int main()
{
    std::cout << "Enter a number: "; // ask user for a number
 
    int x{ }; // define variable x to hold user input (and zero-initialize it)
    std::cin >> x; // get number from keyboard and store it in variable x
 
    std::cout << "You entered " << x << '\n';
    return 0;
}

Enter a number: 4
You entered 4