小编dan*_*992的帖子

如何在不输入".txt"的情况下保存文本文件?

我的程序(c ++):

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;

float x, y, z;
char d[20];

int main()
{   
    cin.getline >>d;
    x=111;
    y=222;
    z=333;
    ofstream meuarquivo;
    meuarquivo.open (d".txt");
    meuarquivo << x << "\n";
    meuarquivo << y << "\n";
    meuarquivo << z << "\n";

    meuarquivo.close ();

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我想写一些类似"ThatsMyProgram"的东西,我希望程序将此文件保存为"ThatsMyProgram.txt".我怎样才能做到这一点?

c++

2
推荐指数
1
解决办法
209
查看次数

标签 统计

c++ ×1