注册 登录
编程论坛 C语言论坛

文件输出出现问题,请大神指教

宋宇轩 发布于 2022-08-31 20:32, 1037 次点击
目的:输入一个int,然后存到ss.docx里(与cpp文件在同一文件夹)
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    ofstream outfile;
    outfile.open("ss.docx", ios::out);
    return 0;   
}
结果ss.docx里没有出现输入的数,帮忙看一下哈。
3 回复
#2
apull2022-08-31 21:46
outfile.open只是打开了文件,并没有输出的步骤呀。
这句后面加上
outfile << a;
outfile.close();

[此贴子已经被作者于2022-8-31 21:48编辑过]

#3
rjsp2022-09-01 00:34
另外,docx 是ms office的文档类型吧
#4
宋宇轩2022-09-01 18:03
谢谢各位
1