'c'编程中的文件处理中的EOF是什么 [英] what is EOF in file handling in 'c' programming

查看:75
本文介绍了'c'编程中的文件处理中的EOF是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生!什么是"c"编程中的EOF.
主题是文件处理.

sir! what is EOF in ''c'' programming.
topic is file handling.

推荐答案

任何编程语言中的EOF都用于文件尾.

因此,如果您尝试显示文件的内容并希望在文件结束时停止,则可以使用该条件检查EOF.

例如:-


EOF in any programming language is for End Of File.

So if you are trying to display the contents of file and want to stop when the file ends, you can use the condition to check EOF.

For example: -


/* Program to display the contents of a file on screen */
#include <stdio.h>
void main()
{
   FILE *fopen(), *fp;
   int c;
   fp = fopen("prog.c","r");
   c = getc(fp) ;
   while (c!= EOF)
   {
        putchar(c);
        c = getc(fp);
        printf("%c", c);
   }
   fclose(fp);
   getch();
}




希望这会有所帮助.让我知道您是否需要更多帮助.

-
AJ




Hope this is helpful. Let me know if you need more help.

--
AJ


这篇关于'c'编程中的文件处理中的EOF是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆