C 语言教程 C 语言实例 - 输出当前文件执行代码

fredrick · 2022-04-04 12:48:54 · 热度: 14

输出当前文件执行代码,__FILE__ 为当前执行的文件常量。

实例

#include <stdio.h> int main() { FILE *fp; char c; fp = fopen(__FILE__,"r"); do { c = getc(fp); putchar(c); } while(c != EOF); fclose(fp); return 0; }

输出结果为:

#include <stdio.h>
int main() {
    FILE *fp;
    char c;
    fp = fopen(__FILE__,"r");
    do {
         c = getc(fp);
         putchar(c);
    }
    while(c != EOF);
    fclose(fp);
    return 0;
}

查看更多 C 语言实例

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册