I am attempting to familiarize myself with BASH so i can work in a Unix environment. I want to export a shell variable to a simple C program but seem to be unable to do so.
Here is the C program: (i am also very unfamiliar with C but this came from a tutorial so i don't think it is is incorrect)
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char *myenvvar=getenv("EDITOR");
printf("The editor environment variable is set to %s\n",myenvvar);
}
i compile it and have the executable all set and ready, and then in BASH i was thinking something as simple as "> export $EDITOR='emacs' \n" should work and export the shell variable to someplace my C program can access it.
Am i making some stupid mistake? (i hope i am) or do i have this totally wrong?
Thanks