Can someone please help me figure out why I'm not getting the results im supposed to? from the textbook
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *my_env[] = {"JUICE = peaches and apples", NULL};
execle("diner info", "diner info", "4", NULL, my_env);
printf("Diners: %s\n", argv[1]);
printf("Juice env: %s\n", getenv("JUICE"));
return 0;
}
The program prints
Diners: (null)
Juice env: (null)`
Try it as it is shown in the text book:
They are 2 programs:
The first program prepares an environment and passes it to a second program that it also executes.
The second program reads its environment and prints it.
Terminal:
Mixing the code and squeezing everything into one file will not work.