#include <vector>
#include <stdio.h>
#pragma warning(disable:4996)
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
using namespace std;
#include <graphics.h>
#include <conio.h>
#include <stdio.h>
#include<windows.h>
#include <time.h>
void main(void)
{
//利用ofstream类的构造函数创建一个文件输出流对象来打开文件
ofstream fout("file1.txt");
if (!fout)
{
cout << "文件不能打开" << endl;
}
else
{
// 输出到磁盘文件
fout << "abcdef" << endl;
fout << "ghijklm" << endl;
//关闭文件输出流
fout.close();
}
ifstream fin("file1.txt");
if (!fin)
{
cout << "文件不能打开" << endl;
}
else
{
string x;
while (getline(fin, x)) {
for (int i = 0; i < x.size(); i++) {
printf("%c", x.at(i) -32);
}
cout << endl;
}
fout.close();
}
}
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632