I get a warning
warning: comparison between pointer and integer
on the line containing if from the next piece of code:
if
In the return types section of the following link, getcwd returns null on failure. Thus, instead of checking for != (char *)NULL just check for != NULL
!= (char *)NULL
!= NULL
http://linux.die.net/man/3/getcwd