fopen(文件名,"w+")你都清空了,还追加个鬼啊w+方式以可读写的方式打开文件,若文件存在则先将文件清空,若文件不存在则创建该文件。
std::ofstream file("filename", std::ios_base::trunc|std::ios_base::out);