Example 1

#include <stdio.h>
main()
{
/* using the returned values in conditional statements */
FILE *fp;
char buff[181];
int more_data;

if ((fp = fopen("MYFILE.DAT","r")) == NULL)
       printf("file not found\n");
else {
       printf("file found\n\n");
       /* loop and print until we reach the end of file */
       while ((more_data = fgets(buff, 180, fp)) != NULL)
              printf(buff);
       }
}