源程序:
#include < iostream>
#include < fstream >
using namespace std;
void main()
{
char *p = "C++程序设计" ;
ofstream myFile("c:\\C++_9_5_2.txt");
//在工程文件的根目录下会产生文本文件"C++_9_5_2.txt"
myFile << p; //将字符指针指向的字符串写到文本文件中
}
运行结果:
原文:https://www.cnblogs.com/duanqibo/p/11900293.html