zl程序教程

您现在的位置是:首页 >  后端

当前栏目

c++通用写文件调试代码

2023-09-27 14:20:25 时间

#include <stdio.h>
#include <sstream>
#include <iostream>

std::stringstream strs;
strs <<id;

std::string temp_str = strs.str();
char* id_char = (char*)temp_str.c_str();

// for debug
char filename[256];
sprintf(filename, "%s%s%s", "D:\\",  id_char, ".png");

FILE* fp = fopen(filename, "wb");
if (!fp) {
    printf("!!! Failed to create file on the disk\n");
    return;

}

fwrite(data, data_length, 1, fp);
fclose(fp);