歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> C語言中關於文件的保存和讀取的程序

C語言中關於文件的保存和讀取的程序

日期:2017/3/1 9:37:03   编辑:Linux編程

#include<stdio.h>


int main(int argc,const char*argv[])

{

//文件的保存

FIlE * fp1;

fp1=fopen("//users//huangqiaoping//Desktop//ok.txt","w");

fprintf(fp1,"兄弟連 我來了");

int hp=100;

fprintf(fp1,"\n是時候奮斗一下了%");

fclose(fp1);


//文件的讀取

fp1=fopen("//users//huangqiaoping//Desktop//ok.txt","r");

char msg[20000];

int n=0;

while(1)

{

fscanf(fq1,"%c",&msg[n])

if(msg[n]==EOF)

{

break;


}

n++;

}

printf("讀取的文件內容是:%s",msg);

fclose(fp1);

return 0;

}

C++ Primer Plus 第6版 中文版 清晰有書簽PDF+源代碼 http://www.linuxidc.com/Linux/2014-05/101227.htm

讀C++ Primer 之構造函數陷阱 http://www.linuxidc.com/Linux/2011-08/40176.htm

讀C++ Primer 之智能指針 http://www.linuxidc.com/Linux/2011-08/40177.htm

讀C++ Primer 之句柄類 http://www.linuxidc.com/Linux/2011-08/40175.htm

將C語言梳理一下,分布在以下10個章節中:

  1. Linux-C成長之路(一):Linux下C編程概要 http://www.linuxidc.com/Linux/2014-05/101242.htm
  2. Linux-C成長之路(二):基本數據類型 http://www.linuxidc.com/Linux/2014-05/101242p2.htm
  3. Linux-C成長之路(三):基本IO函數操作 http://www.linuxidc.com/Linux/2014-05/101242p3.htm
  4. Linux-C成長之路(四):運算符 http://www.linuxidc.com/Linux/2014-05/101242p4.htm
  5. Linux-C成長之路(五):控制流 http://www.linuxidc.com/Linux/2014-05/101242p5.htm
  6. Linux-C成長之路(六):函數要義 http://www.linuxidc.com/Linux/2014-05/101242p6.htm
  7. Linux-C成長之路(七):數組與指針 http://www.linuxidc.com/Linux/2014-05/101242p7.htm
  8. Linux-C成長之路(八):存儲類,動態內存 http://www.linuxidc.com/Linux/2014-05/101242p8.htm
  9. Linux-C成長之路(九):復合數據類型 http://www.linuxidc.com/Linux/2014-05/101242p9.htm
  10. Linux-C成長之路(十):其他高級議題

Copyright © Linux教程網 All Rights Reserved