能打印自己源码的C程序的版本2
版本2
#include <stdio.h>; int main() { FILE *f; char c; if ( ( f = fopen( __FILE__, "r" ) ) != NULL ) { while ( fread( &c, 1, 1, f ) == 1 ) fwrite( &c, 1, 1, stdout ); fclose( f ); } return 0; }
增加语言的了解程度可以避免写出愚蠢的代码
版本2
#include <stdio.h>; int main() { FILE *f; char c; if ( ( f = fopen( __FILE__, "r" ) ) != NULL ) { while ( fread( &c, 1, 1, f ) == 1 ) fwrite( &c, 1, 1, stdout ); fclose( f ); } return 0; }