I get a warning
warning: comparison between pointer and integer
on the line containing if from the next piece of code:
if
have you included the .h necessary so that the compiler understands what getcwd returns?
the behavior of your c compilers is probably to assume an int return value from every undefined function.