奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

C語言

c語言文件創建與建立

時間:2024-05-31 02:55:27 C語言 我要投稿

c語言文件創建與建立

  C語言是一門通用計算機編程語言,應用廣泛。下面是小編分享的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");

  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;< p="">

  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;

  }

  知識點:以文件的創建為例,我們在頭文件中使用# include包含了ofstream類,并且在主程序中使用類ofstream建立了名為outclientfile對象,并且初始化其構造函數。要注意的是我們在while只是判斷條件的真假,而類outclientfile進行輸入數據。

【c語言文件創建與建立】相關文章:

C語言文件的創建與建立08-12

怎么利用c語言創建excel文件08-13

C語言文件08-28

C語言的文件概念07-18

C語言文件操作教程09-07

C語言頭文件封裝06-25

C語言項目中.h文件和.c文件的關系詳解10-01

C語言文件的使用方法08-01

C語言文件操作函數freopen詳解07-13

C語言怎樣創建windows窗口08-19

主站蜘蛛池模板: 舟山市| 新河县| 赣榆县| 阳泉市| 青海省| 凌源市| 南和县| 大竹县| 黔江区| 长泰县| 滦南县| 疏附县| 逊克县| 彭山县| 温州市| 噶尔县| 四平市| 儋州市| 封丘县| 咸阳市| 佛学| 建昌县| 日照市| 钟祥市| 巫山县| 大同市| 邹城市| 安徽省| 肃宁县| 万安县| 商南县| 扎囊县| 英山县| 资溪县| 黎川县| 安康市| 宁明县| 和硕县| 三门县| 洪洞县| 宁陕县|