美文网首页
C++自学计划-输入输出-14

C++自学计划-输入输出-14

作者: 你缺少想象力 | 来源:发表于2018-12-20 16:03 被阅读0次

这里主要讲解4中操作:

  1. 输入
  2. 输出
  3. 错误输出
  4. 日志输出

要用到IO库文件iostream

例子:

#include <iostream>

using namespace std;

int main() {
    // 输出
    cout << "hello world" << endl;

    char name[5];
    // 输入
    cin >> name;
    cout << name << endl;

    // 错误输出
    cerr << "error" << endl;
    // 日志输出
    clog << "log" << endl;

    return 0;
}

运行结果:

hello world
hi
error
hi
log

相关文章

网友评论

      本文标题:C++自学计划-输入输出-14

      本文链接:https://www.haomeiwen.com/subject/mfidkqtx.html