C program to Reads strings from the file and displays them on screen

C program to Reads strings from the file and displays them on screen

#include "stdio.h" 
main( ) 
{ 
 FILE *fp ; 
 char s[80] ; 
 fp = fopen ( "POEM.TXT", "r" ) ; 
 if ( fp == NULL ) 
 { 
 puts ( "Cannot open file" ) ; 
 exit( ) ; 
 } 
 while ( fgets ( s, 79, fp ) != NULL ) 
 printf ( "%s" , s ) ; 
 fclose ( fp ) ; 
} 

And here is the output…
Shining and bright, they are forever,
so true about diamonds,
more so of memories,
especially yours !

Leave a Comment