【问题标题】:How to print Content of currently Executing file C++?如何打印当前执行文件 C++ 的内容?
【发布时间】:2021-02-20 14:14:27
【问题描述】:

如何在 C++ 中打印当前正在执行的文件的所有内容?

#include <iostream>
using namespace std;

int main() {
    // some code that print current file.
}

预期输出:

#include <iostream>
using namespace std;

int main() {
    // some code that print current file.
}

【问题讨论】:

    标签: c++ operating-system


    【解决方案1】:

    可能有很多方法,简单的一种。

    #include <iostream>
    using namespace std;
    
    int main() {
        string more = "more ";
        more.append(__FILE__);
        system(more.c_str());
    
    }
    

    输出:

    #include <iostream>
    using namespace std;
    
    int main() {
        string more = "more ";
        more.append(__FILE__);
        system(more.c_str());
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-14
      • 2015-06-28
      • 2011-08-26
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多