C++中将字符串写入txt

#include
#include
#include
using namespace std;


int main(){
    char buffer[512];
    std::fstream fs;
    std::ifstream ifs;


    fs.open("D://fs.txt",std::fstream::in|std::fstream::out|std::fstream::app);
    /*
    检查有没有这个文档,没有创建他
    */
    fs.close();
    std::ofstream ofs;


    char x[10000];
    ofs.open("D://fs.txt",std::fstream::out|std::fstream::app);
    std::cin>>x;
    ofs<     ofs.close();


    ifs.open("D://fs.txt",std::fstream::out|std::fstream::in|std::fstream::app);
    memset(buffer,0,sizeof(buffer));//清空缓存


    ifs>>buffer;
    cout<<"D://fs.txt\r"<

    return 0;
}

你可能感兴趣的:(C++中将字符串写入txt)