100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > C++文件操作无法写入的问题

C++文件操作无法写入的问题

时间:2018-11-16 02:26:28

相关推荐

C++文件操作无法写入的问题

今天测试C++文件操作时,始终无法将数据写入文件中,百思不得其解,最后发现文件操作完成后一定要将文件关闭,即调用close()函数。

#include <iostream>#include <fstream>#include <string>using namespace std;int main(){/*fstream file1;ofstream file2;file1.open("A.dat", ios::in);file2.open("abc.dat", ios::trunc);double temp,data[1600];int index = 0;for(int i=0;i<1600;i++){//file1 >> temp;//data[i] = temp;file2 <<i;//if (i % 40 == 0)file2 << "\n";index++;}*/ofstream file3;file3.open("b.txt", ios::trunc);for (int j = 0; j < 16; j++){file3 <<j;file3 << " ";}file3.close();cout << "succed";int abc;cin >> abc;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。