Example of realpath function in C

前端 未结 4 843
忘掉有多难
忘掉有多难 2020-12-09 17:49

I\'m looking for an example of how to use the realpath function in a C program. I can\'t seem to find one on the web or in any of my C programming books.

4条回答
  •  心在旅途
    2020-12-09 18:03

    Like this:

    int main(int argc, char *argv[]) {
        ...
        char *symlinkpath = argv[1];
        char actualpath [PATH_MAX];
        char *ptr;
        ptr = realpath(symlinkpath, actualpath);
        ...
    }
    

    Borrowed from here

提交回复
热议问题