欧美日韩不卡一区二区三区,www.蜜臀.com,高清国产一区二区三区四区五区,欧美日韩三级视频,欧美性综合,精品国产91久久久久久,99a精品视频在线观看

C語(yǔ)言

c語(yǔ)言—文件的創(chuàng)建與建立

時(shí)間:2025-01-12 06:57:54 C語(yǔ)言 我要投稿

c語(yǔ)言—文件的創(chuàng)建與建立

  今天要介紹的是有關(guān)文件的創(chuàng)建與讀取的語(yǔ)法,事實(shí)上,c語(yǔ)言中對(duì)于這方面的已經(jīng)有相當(dāng)經(jīng)典且應(yīng)用相當(dāng)廣泛的語(yǔ)法了,但是我今天想講一講關(guān)于c++中的相關(guān)語(yǔ)法,以下僅供參考!

  以下是代碼:

  首先是文件的創(chuàng)建:

  # 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");

  return 0;

  }

  以下是文件的讀。

  # include

  # include

  # include

  # include

  # include

  using namespace std;

  void outputline(int, const string, double);

  int main() {

  ifstream inclientfile("clients.dat", ios::in);

  if (!inclientfile) {

  cerr << "file could not be opened" << endl;

  exit(1);

  }

  int account;

  char name[30];

  double balance;

  cout << left << setw(10) << "account" << setw(13) << "name"

  << "balance" << endl<<fixed<<showpoint;

  while (inclientfile >> account >> name >> balance) {

  outputline(account, name, balance);

  }

  system("pause");

  return 0;

  }

  void outputline(int account, const string name, double balance) {

  cout << left << setw(10) << account << setw(13) << name

  << setw(7) << setprecision(2) << right << balance << endl;

  }

【c語(yǔ)言—文件的創(chuàng)建與建立】相關(guān)文章:

c語(yǔ)言文件創(chuàng)建與建立05-31

C語(yǔ)言文件的創(chuàng)建與建立08-12

怎么利用c語(yǔ)言創(chuàng)建excel文件08-13

C語(yǔ)言文件08-28

C語(yǔ)言的文件概念07-18

C語(yǔ)言頭文件封裝06-25

C語(yǔ)言文件操作的方法09-17

C語(yǔ)言文件操作函數(shù)10-18

C語(yǔ)言文件操作教程09-07