输入输出 2016/8/28
使用的教材: 《c++ Primer》(5th)
编译器+IDE:codeblocks-mingw
P5
一.Iostream库的简介
Iostream库包含两个基础类型,分别是istream输入流,ostream输出流;
二.标准I/O对象 (input/output)
标准库(standard library)一共定义了4个IO对象,不常用的两个是报错的cerr,输出程序运行时信息的clog;常用的是输入cin,输出cout。
那么具体如何输出 or 输入呢?看源代码:
std::cout << "hello world" << std::endl;
也可以分步为:
std::cout << "hello world";
std::cout << std::endl;
先是处理std::cout << "hello world"; 其中std::是指名字cout是在std的namespace(命名空间)中,这是为了避免名字冲突,但命名时需要加上作用域运算符:: ,写成std::cout的形式。
<<是输出运算符,它接受两个运算对象,<<将 "hello world"写入到std::cout中,最后<<的运算结果就是左侧的运算对象std::cout
"hello world"处理完了,然后再处理std::cout << std::endl; endl是manipulator(操纵符),基本作用是结束这一行。
编译器+IDE下载: http://pan.baidu.com/s/1geAgFMr