《C语言程序设计》(第3版_乌云高娃)-11章 同步实训指导参考答案 同步实训指导参考答案10.1.docVIP

  • 7
  • 0
  • 约小于1千字
  • 约 2页
  • 2021-09-11 发布于湖北
  • 举报

《C语言程序设计》(第3版_乌云高娃)-11章 同步实训指导参考答案 同步实训指导参考答案10.1.doc

深圳职业技术学院 C语言程序设计 PAGE 2 同步实训指导参考答案 任务1:从键盘输入一个字符串,然后保存在文件“”中。 #include stdio.h void main() { FILE *fp; char chInfo[20]; int i; fp=open(myInfo.txt,w); if(fp==-1){ printf(cannot open this file!\n); exit()); } printf(please input a string:); scanf(%s,chInfo); write(fp,chInfo,10) ; close(fp); getch(); } 任务2:将“”的内容输出在屏幕上。 #include stdio.h void main() { FILE *fp; char chInfo[10]; fp =open(myInfo.txt,r); if(fp==-1){ printf(cannot open this file!\n); exit(0); } read(fp,chInfo,10) ; printf(%s,chInfo);

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档