If getenv is supposed to return a pointer to the value in the environment shouldn't this program work for printing out the string value of the environment variable?
#include <stdio.h>
#include <unistd.h>
int main() {
printf("HOME=%s\n",getenv("HOME"));
return 0;
}
I am getting the following warning when I compile:
format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’
And when I run the program I get a Segmentation Fault.
I am using Ubuntu and I am wondering if this has to do with permissions or another form of security.