dirt2

代码如下:

    char current_absolut_path[MAX_SIZE] = "";
    memset(current_absolut_path,0,MAX_SIZE);
    //获取当前程序绝对路径
    int cnt = readlink("/proc/self/exe", current_absolut_path, MAX_SIZE);
    if (cnt < 0 || cnt >= MAX_SIZE)
    {

    }
    else
    {
        //获取当前目录绝对路径,及去掉程序名
        int i;
        for (i = cnt; i >= 0; --i)
        {
            if (current_absolut_path[i] == \'/\')
            {
                current_absolut_path[i+1] = \'\0\';
                break;
            }
        }
    }

 

分类:

技术点:

相关文章:

  • 2021-06-26
  • 2021-09-26
  • 2022-01-10
  • 2022-01-19
  • 2021-10-01
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-12-17
  • 2022-01-30
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-02-18
  • 2022-02-26
相关资源
相似解决方案