cout cin - ShenYj/ShenYj.github.io GitHub Wiki

cout、cin

前言

如果你想做个普通的程序员,学好所熟悉的语言基本够用,如果你的理想还要更大一点,C++是进阶必备

cout

任何语言的学习都离不开那句经典的 “Hello World!”

C++ 中输出函数: cout

cout <<

先要导入库

#include <iostream>
using namespace std;

需要换行只需要在最后加上 endl, 完整的 "Hello World!" 输出并换行即:

cout << "Hello World!" << endl;

cin

从键盘读取内容

int age;
cin >> age;

/// 将录入的 age 值 通过 cout 函数输出
cout << "age is:" << age << endl;
⚠️ **GitHub.com Fallback** ⚠️