请注意程序运行时将不能访问到源程序(系统已经将源代码删除)。
[此贴子已经被作者于2005-7-17 0:32:43编辑过]
我写了个,目前只想到这么做。。。 #include <stdio.h>
#define Line1 "#include <stdio.h>" #define Line2 "int main()" #define Line3 "{" #define Line4 "printf(\"Hello,world\\n\");" #define Line5 "return 0;" #define Line6 "}"
int main() { FILE *fp=fopen("MySrc.c","w"); printf("Hello,world\n"); fprintf(fp,"%s\n%s\n%s\n%s\n%s\n%s\n",Line1,Line2,Line3,Line4,Line5,Line6); fclose(fp); return 0; }
按照题目要求,楼上的程序输出结果应该是: #include <stdio.h>
#define Line1 "#include <stdio.h>" #define Line2 "int main()" #define Line3 "{" #define Line4 "printf(\"Hello,world\\n\");" #define Line5 "return 0;" #define Line6 "}"
int main() { FILE *fp=fopen("MySrc.c","w"); printf("Hello,world\n"); fprintf(fp,"%s\n%s\n%s\n%s\n%s\n%s\n",Line1,Line2,Line3,Line4,Line5,Line6); fclose(fp); return 0; }