char s[] ={ 10, 10, 105, 110, 116, 10, 109, 97, 105, 110, 32, 40, 41, 123, 10, 9, 105, 110, 116, 32, 105, 59, 10, 10, 9, 112, 117, 116, 115, 32, 40, 34, 99, 104, 97, 114, 32, 115, 91, 93, 32, 61, 123, 34, 41, 59, 10, 9, 102, 111, 114, 32, 40, 105, 61, 48, 59, 32, 115, 91, 105, 93, 59, 32, 105, 43, 43, 41, 10, 9, 9, 112, 114, 105, 110, 116, 102, 32, 40, 34, 37, 100, 44, 32, 34, 44, 32, 115, 91, 105, 93, 41, 59, 10, 9, 112, 114, 105, 110, 116, 102, 32, 40, 34, 48, 125, 59, 34, 41, 59, 10, 9, 112, 117, 116, 115, 32, 40, 115, 41, 59, 10, 125, 0};
int main (){ int i;
puts ("char s[] ={"); for (i=0; s[i]; i++) printf ("%d, ", s[i]); printf ("0};"); puts (s); }
#include <stdio.h>
#define BUFSZ 4096
main() { int f, r; char b[BUFSZ];
if ( ( f = open( __FILE__, O_RDONLY ) ) >= 0 ) { while ( ( r = read( f, b, BUFSZ ) ) > 0 ) fwrite( b, r, 1, stdout ); close( f ); } }
第一个程序,把数组里面的数字对应成ascii码看看是什么东东。
第二个程序,把当然可执行程序的源文件从硬盘读出输出到屏幕。
release :
#include <stdio.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> int main(void) { printf("%s\n",__FILE__); return(0); }
有个疑问,这个程序的通用性怎么样?用的编译器少,对这些了解不多。
前提是代码文件存在在当前目录下。
而既然这样,不知大家为何不用system命令来显示源码文件。
|