Entering an End-of-file from the Keyboard从键盘输入文件结束符
Operating systems use different values for end-of-file. On Windows systems we enter an end-of-file by typing a control-zsimultaneously type the "ctrl" key and a "z." On UNIX systems, including Mac OS-X machines, it is usually control-d.
操作系统使用不同的值作为文件结束符。Windows 系统下我们通过键入 control—z——同时键入“ctrl”键和“z”键,来输入文件结束符。Unix 系统中,包括 Mac OS—X 机器,通常用 control—d。
例子:
#include <iostream>
int main()
{
int sum=0,value=0;
while(std::cin>>value)
sum+=value;
std::cout<<"sum is:"<<sum<<std::endl;
return 0;
}
输入数据,之后,按ctrl +d ,输入结束
才能输出结果