C语言文件的创建与建立
c语言中对于文件的创建与建立已经有相当经典且应用相当广泛的语法了。下面是小编为大家带来的C语言文件的创建与建立的知识,欢迎阅读。
首先是文件的创建:
# include
# include
# include
using namespace std;
int main() {
ofstream outclientfile("clients.dat", ios::out);
if (!outclientfile) {
cerr << "file could not be opend" << endl;
exit(1);
}
cout << "enter the account,name,and balance." << endl;
cout<< "enter end-of-file to end input.
?";
int account;
char name[30];
double balance;
while (cin >> account >> name >> balance) {
outclientfile << account << " " << name << " " << balance << endl;
cout << "?";
}
system("pause");