scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0092-getenv.c (407B)


      1 #include <assert.h>
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <string.h>
      5 
      6 /*
      7 output:
      8 testing
      9 done
     10 end:
     11 */
     12 
     13 int putenv(char *);
     14 
     15 int
     16 main(void)
     17 {
     18 	char *s;
     19 
     20 	puts("testing");
     21 	s = getenv("THIS_CANNOT_BE_A_ENV_CAR");
     22 	assert(s == NULL);
     23 
     24 #if defined(__unix__) || defined(__SCC_PUTENV__)
     25 	putenv("AVAR=avalue");
     26 	s = getenv("AVAR");
     27 	assert(strcmp(s, "avalue") == 0);
     28 #endif
     29 	puts("done");
     30 
     31 	return 0;
     32 }