【发布时间】:2016-06-02 10:57:11
【问题描述】:
我想用 C++ 代码将这些数据写入文件中的数组 请帮帮我! 这段代码很好,但我想把它写在数组上! 我应该添加什么来将它写在数组上!
#include <iostream>
#include <fstream>
#include<string>
using namespace std;
int main(){
ofstream file("BooksList.txt");
if (file.is_open()){
file <<"[1]Programming Languages:Principles and Practice\t\tKenneth C. Louden\t\t\t0534953417"<<endl;
file <<"[2]Programming Languages:Principles and Paradigms\t\tAllen Tucker and Robert Noonan\t\t0071122800"<<endl;
file <<"[3]File Structures:An Object-Oriented Approach with C++\t\tMichael Folk and Bill Zoellick\t\t0201874016"<<endl;
file <<"[4]Data Structures Using C++\t\t\t\t\tD.S Malik\t\t\t\t0324782012"<<endl;
file <<"[5]Fundamentals of Web Development\t\t\t\tRandy Connolly\t\t\t\t0133407152"<<endl;
file <<"[6]Data Structures and Algorithms in Java\t\t\tGoodrich and Tamassia\t\t\t0471738840"<<endl;
cout<<"written successfully !";
}else{
cout<<"File Not Found !- ERROR";
}
return 0;
}
【问题讨论】:
-
我不明白这个问题。 “将此数据写入文件中的数组”是什么意思?
标签: c++ arrays file main ostream