Setting value to an environment variable

ascii-table     avg.txt               case-changer.c  env-var-set.c     functions_ver2.c  output.c
ascii-table.c   avg-with-garbage.txt  env-var          mph-to-kph.c  case-changer          env-var.c       functions_ver1.c  mph-to-kph_v2.c
$cat env-var-set.c 
#define _POSIX_C_SOURCE 200112L
#include <stdio.h>
#include <stdlib.h>

int main(void)
    setenv("FULLNAME", "Jack-Benny", 1);
    printf("Your full name is %s\n", getenv("FULLNAME"));
    return 0;
$gcc env-var-set.c -o env-var-set

Your full name is Jack-Benny

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: