ccplusplus.com
Learn C, C++ Concepts
Friday, January 6, 2012
c code to display content of a file
/******************************************************************* * File : display-file-content.c * Author : Saurabh Gupta * Description : c code to display content of a file * Date : PM 09:50 06 January 2012 * Source : http://www.ccplusplus.com/p/c.html *******************************************************************/ #include <stdio.h> void main() { FILE *fopen(), *fp; int c ; fp = fopen( "ccplusplus.com", "r" ); c = getc( fp ) ; while ( c != EOF ) { putchar( c ); c = getc ( fp ); } fclose( fp ); } /* * OUTPUT * [sgupta@rhel6x64 file-handling]$ gcc -o display-file-conten display-file-content.c [sgupta@rhel6x64 file-handling]$ ./display-file-conten XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XX www.ccplusplus.com XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [sgupta@rhel6x64 file-handling]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment