home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_11 / 8n11032a < prev    next >
Text File  |  1990-09-18  |  653b  |  37 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. main()
  7. {
  8.     char *pc;
  9.     char ev[] = "test=1234";
  10.  
  11.     if (putenv(ev) == -1)
  12.         printf("cannot define string\n");
  13.     else {
  14.         printf("string definition added\n");
  15.         pc = getenv("test");
  16.         printf("string defined as >%s<\n", pc);
  17.  
  18.         ev[6] = 'x';
  19.         pc = getenv("test");
  20.         printf("string defined as >%s<\n", pc);
  21.  
  22.         strcpy(ev, "xyz");
  23.         pc = getenv("test");
  24.         if (pc == NULL)
  25.             printf("no such string\n");
  26.         else
  27.             printf("string defined as >%s<\n", pc);
  28.         system("see");
  29.     }
  30. }
  31.  
  32. string definition added
  33. string defined as >1234<
  34. string defined as >1x34<
  35. no such string
  36.  
  37.