一、今日学习
46.1格式输出
将1000以内所有的素数输出到C盘根目录文件Prime.txt中,每一行只输出一个素数。将程序和输出文件一起打包。
实验要求:
1.注意加上必要的输入输出提示;
2.注意开头的标注部分,加上自己的姓名以及修改日期;
3.使用流对象的成员函数实现
46.2字符输入操作
键盘输入“I am a student./ My university is STDU./ I love my university.”
用流对象的成员函数get读取并打印到屏幕上;
分别用流对象的成员函数get函数和getline函数读取第一个“/”之前的字符串,之后观察当前指针所指内容,观察是否有差别,若有,请在实验报告中描述;
先读取第一个“/”前的字符串打印至屏幕,再读取第二个“/”后的字符串打印至屏幕。
实验要求:
1.注意加上必要的输入输出提示;
2.注意开头的标注部分,加上自己的姓名以及修改日期;
46.3使用I/O流以文本方式建立一个文件test1. txt,写入字符“已成功写人文件!”,用其他字处理程序(例如Windows的记事本程序Notepad)打开,看看是否正确写入。