zoukankan      html  css  js  c++  java
  • c++ ------------------------------>>>>>>>程序获取当前的路径

    https://blog.csdn.net/suiyueruge1314/article/details/106407842

    Linux下,c++获取当前程序路径

    #include <stdio.h>
    #include <unistd.h>

    char *buffer;
    buffer = getcwd(NULL, 0);
    cout << "文件路径" << buffer << endl;
    //将需要调用的模块使用 strcat 作拼接;
    const char *model_path = strcat(buffer,"/models");

    或者:

    #include <stdio.h>
    #include <unistd.h>
    int main()
    {
    char *buffer;
    if((buffer = getcwd(NULL, 0)) == NULL)
    {
    perror("getcwd error");
    }
    else
    {
    printf("%s ", buffer);
    }
    }
    此程序是获取当前程序的绝对路径的方法.
    有的文章包含的头文件是<direct.h>,在linux下,貌似不是这样的.
    至于在那用到direct.h,这就不知道了.

    17
    参考自:
    https://blog.csdn.net/liangxiaozhang/article/details/7704742?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-2
    ————————————————
    版权声明:本文为CSDN博主「Zero_to_zero1234」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/suiyueruge1314/article/details/106407842

  • 相关阅读:
    算法很美(一)
    pytest学习(四)
    pytest学习(三)
    pytest学习(二)
    pytest学习(一)
    HTTP协议详细介绍,面试详全强助攻!
    Docker实战总结
    微信小程序测试整理
    这些用例设计题,你在面试时遇到过吗?
    测试面试题集-Dubbo常见面试题(12)
  • 原文地址:https://www.cnblogs.com/shuimuqingyang/p/14484763.html
Copyright © 2011-2022 走看看