11-4

使用I/O流以文本方式打开上一题建立的文件test1.txt,读出其内容显示出来,看看是否正确。

 1 #include <iostream>
 2 #include <string>
 3 #include<string.h>
 4 #include <fstream>
 5 using namespace std;
 6 
 7 
 8 int main(){
 9     char ch;
10     ifstream file("text1.txt");
11     while(file.get(ch)) cout<<ch;
12     file.close();
13     return 0;
14 }

 

posted @ 2023-03-27 22:27  nlkdfgnvfdkl  阅读(39)  评论(0)    收藏  举报