Jam
Jam

Reputation: 113

How to get a relative path in c

pwd prints the absolute path of the current working directory by using getcwd() function.

So, is there a function that returns relative path of the current working directory in c?

Upvotes: 0

Views: 2594

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137398

So, is there a function that returns relative path of the current working directory in c?

Relative paths are usually relative to the current working directory. So your question doesn't really make sense.

The only answer valid would be:

const char *get_rel_cwd(void)
{
    return ".";
}

Upvotes: 3

Related Questions