手机版
你好,游客 登录 注册
背景:
阅读新闻

C语言中关于文件的保存和读取的程序

[日期:2014-11-20] 来源: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成长之路(十):其他高级议题

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-11/109631.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款