getcwd was not declared in this scope

来源:互联网 发布:mysql书籍推荐知乎 编辑:程序博客网 时间:2024/05/21 13:57

Environment: Fedora 22 + QT
Aim: get current working directory.
Code example:

    char* buffer;    if((buffer=getcwd(NULL,0))==NULL){        perror("getcwd error");    }else{        printf("%s\n",buffer);        free(buffer);    }

Error:

getcwd was not declared in this scope

Solution: add following code in your source file:

#include <unistd.h>
0 0
原创粉丝点击