c++输出的问题
C++ Probllem with output
我需要用户键入他想要写入数据的文件。例子:你想写什么文本文件"Hello Too"?他输入to: example,数据将进入example.txt文件,其中包含Hello Too。问题是,它不能采取一个字符串(accname),并结合。txt,使它发送的数据也文本文件。这很难解释,希望你能理解:D
int Transfersum;
string accname;
cout << "Type the account name you want to send too" << endl;
cin >> accname;
ofstream mfile;
mfile.open ( accname ".txt");
mfile << Transfersum;
mfile.close();
您必须连接accname + ".txt"
以将其用作mfile.open ()
调用的参数表达式。
您应该能够使用+
的字符串连接。
mfile.open ( accname + ".txt");
如果你不是在c++ 11
,那么你可能需要一个c风格的字符串。
mfile.open ( (accname + ".txt").c_str());
相关文章:
- C++格式化输出问题
- 输出错误,问题是找到总和5000位数字cpp
- 无法在问题解决方案中执行输出逻辑
- C++ 每次运行程序时我都会"nan"输出的问题
- 遇到此问题时遇到困难:允许用户输入数组的值并使用 for,而循环也输出输入的最大数字
- 这是使用回溯的 nqueen 问题,但我使用了动态 2d 数组,我的程序编译良好,但不返回任何输出
- OpenCV 傅里叶变换复杂输出问题
- 阶乘问题在 c++ 中给出错误的输出
- 在 C++ 中实现简单链表时出现问题,没有输出
- 是给定代码中的任何更改,以便我可以为问题提供正确的输出
- 在黑客地球上没有获得以下C ++代码问题的输出
- 数组为此合并排序函数提供了正确的输出,但向量给出了不正确的输出.出了什么问题?
- 我的输出结果是 0 英寸C++.可能是什么问题
- c ++:我没有得到正确的输出(菜鸟问题)
- 代码输出随机符号,我不确定出了什么问题
- C++问题,我的两个源代码应该具有相同的输出,但它们是不同的
- C++ 回文程序总是给出 0(假)作为输出问题;我的代码哪里有问题?
- 未获得 N-皇后问题的预期输出
- 堆排序,我无法弄清楚我的代码出了什么问题,输出顺序不正确
- 编译 gsoap 输出文件 (onvif) 时出现问题