spd是什么意思啊:c++如何把一个变量中的值写入文本文件。。。

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/12 19:31:26
比如把某字符串赋予一个变量。。。该如何编程。。。

修改了一下:
#include <string>//这一句去掉也对,不知为什么
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
string ss = "abcddddd";//C++标准库引入了string类,这样你就可以直接给这个对象赋值了
ofstream ofile;
ofile.open("c:\\a.txt");
if (!ofile)
{
cerr << "Can not open the file." << endl;
return 0;
}
ofile << ss.c_str();
ofile.close();

return 0;
}

void main()
{string a="shu ru zi fu";

}