fileio.c
上传用户:bjtelijie
上传日期:2010-01-01
资源大小:87k
文件大小:0k
源码类别:

数学计算

开发平台:

Visual C++

  1. # include <stdio.h>
  2. # include <stdlib.h>
  3. void main()
  4. {
  5. /* 定义一个文件指针fp */
  6. FILE *fp;
  7. char ch, filename[10];
  8. printf("Please input the name of file: ");
  9. scanf("%s", filename);  /* 输入字符串并赋给变量filename */
  10. /* 以读的使用方式打开文件filename */
  11. if((fp=fopen(filename, "r")) == NULL)
  12. {
  13. printf("Cannot open the file.n");
  14. exit(0);  /* 正常跳出程序 */
  15. }
  16. /* 关闭文件 */
  17. fclose(fp);
  18. }