This blog is under construction

Saturday, 28 April 2012

feof example in C

Header file:
    stdio.h

Synopsis:
     int feof(FILE *stream);

Description:
     It checks the EOF indicator for the given stream and return non-zero if it is set.


feof function C example:


  #include<stdio.h>
  int main() {
        int c;
        FILE *fp;
        fp = fopen("input.txt", "r");
        while (!feof(fp)) {
                c = fgetc(fp);
                putchar(c);
        }
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/exp$ ./a.out
  Hello world
  Hello world
  Hello world

  jp@jp-VirtualBox:~/cpgms/exp$ cat input.txt
  Hello world
  Hello world
  Hello world

1 comment:

  1. I found best article.thank you for sharing useful info.
    visit
    web programming tutorial
    welookups

    ReplyDelete