Hi in my program there is an option to enter a directory as a command line argument. Is there any check I can perform to see whether this directory is relative to the current working directory?

For example if we are /home/user and the user wants to input /home/user/folder they have to type ./folder.

I need this to keep folder structure. Failing this is there anyway which I can compare two strings to produce the relative paths.

For example I will always have the current working directory in absolute stored in 'cwd' and I will also have the absolute path of the user entered directory stored in 'folder'

Can I compare the two and produce a relative path of 'folder' from 'cwd'?

Thanks for your help

Edit: This program is intended for Ubuntu Linux btw

you can expand ./folder into /home/user/folder by calling cwd(), assuming ./folder is the current working directory. Then you can compare the two absolute paths to see if one is in the other or that they are the same.

You could produce the string ./folder from /home/user/folder, but it won't work if the current working directory is not /home/user. For example if the program changes directory to /etc then ./folder becomes meaningless.