c++ 輸出當前的工作空間路徑


 

getcwd是最方便的方法,只需要包涵頭文件<direct.h>即可.

#include <direct.h>//---getcwd
#include <stdio.h>
#include <stdlib.h>

int main()
{
    //打印輸出當前路徑
    char *buffer;
    //也可以將buffer作為輸出參數
    if((buffer = getcwd(NULL, 0)) == NULL)
    {
        perror("getcwd error");
    }
    else
    {
        printf("path:%s\n", buffer);
        free(buffer);
    }

    return 0;
}

 
        
 

reference

https://blog.csdn.net/fannana2011/article/details/6292607


https://blog.csdn.net/fannana2011/article/details/6292607

 

http://www.vseei.com

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM