So my code breaks down at buffer[i] = envp[i].
I want to create a char**buffer of the environment variables, and make them lower case (didn't add the putc(tolower()) yet loop). But when I just try to make buffer[i] = envp[i], the compiler returns me this error:
error: assignment makes integer from pointer without a cast [-Wint-conversion] buffer[i] = envp[i]; ^
warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=] printf("%s\n", buffer[i]); ~^ ~~~~~~~~~ %d
int main(int argc, char *argv[], char * envp[])
{
int i = 0;
char *buffer = NULL;
while(envp[i])
{
i++;
}
buffer = (char *)malloc(i * 8);
for (i = 0; envp[i] != 0 ; i++)
{
buffer[i] = envp[i];
printf("%s\n", envp[i]);
printf("%s\n", buffer[i]);
}
return 0;
}
Please help, I've been breaking my head here :( . Thanks so much!!!