用ofstream写文本文件

#include <fstream>

int main(int argc,char** argv)
{
    //写一些内容到D盘根目录的myoutput.txt文件中,写C盘会失败,所以选择D盘

    std::ofstream myfile("D:/myoutput.txt");//不存在会创建

    myfile << "name" << "\t" << "score" << std::endl;
    myfile << "Zhang San" << "\t" << "60" << std::endl;
    myfile << "Li Si" << "\t" "100" << std::endl;

    myfile.close();

    return 0;
}

你可能感兴趣的:(C++,c,C#)