Operating Systems - Projects and Exercises

environ.c

The left arrow above will return you to the Home page
The left arrows below will return you to the Previous page

Go back top
/* 
  environ - skeleton program displaying environment
  
  usage:
  
    environ
          
    displays environment with each name, value pair on a separate line

      
 ********************************************************************
   version: 1.0
   date:    December 2003
   author:  Ian G Graham
            School of Information Technology
            Griffith University, Gold Coast
            ian.graham@griffith.edu.au
            
   copyright (c) Ian G Graham, 2003. All rights reserved.
            
   This code can be used for teaching purposes, but no warranty,
   explicit or implicit, is provided.
 *******************************************************************/
 
#include <stdio.h>
#include <stdlib.h>
 
extern char **environ;                   // environment array
 
int main(int argc, char **argv)
{
    char ** env = environ;
 
    while (*env) printf("%s\n",*env++);  // step through environment
 
    exit(0);
}
Go back top

For use only by students and instructors using the supplementary material available with the text book: "Operating Systems - Internals and Design Principles", William Stallings, Prentice Hall, 5th Edition, 2004. Not to be printed out or copied by any other persons or used for any other purpose without written permission of the author(s).

©