| Current Path : /var/www/html/mmishra/nweb/ |
| Current File : /var/www/html/mmishra/nweb/filereadline.c |
#include <stdio.h>
int main ( void )
{
static const char ifilename[] = "index.htm";
static const char ofilename[] = "mm.htm";
FILE *file1 = fopen ( ifilename, "r" );
FILE *file2 = fopen ( ofilename, "w" );
if ( file1 != NULL )
{
char line [ 128 ]; /* or other suitable maximum line size */
while ( fgets ( line, sizeof line, file1 ) != NULL ) /* read a line */
{
//fputs ( line, stdout ); /* write the line */
fputs ( line, file2 ); /* write the line */
}
fclose ( file1 );
fclose ( file2 );
}
else
{
perror ( ifilename ); /* why didn't the file open? */
}
return 0;
}