You forgot to #include <stdlib.h>
. This means that getenv()
isn't declared anywhere, so it's assumed to return an int
by default, which you're casting to char *
. On a 64-bit machine, int
(32 bits) and char *
(64 bits) have different sizes, hence the warning.
As an aside, the cast to char *
is not necessary, since getenv()
already returns a char *
. The cast only serves to mask errors (i.e. without it, the program would have given you a clear error message about passing an int
to a char *
).