System Software Lab Programs ( UNIX Programs ) – 7b

// June 7th, 2009 // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

[Click Here to get other programs by email ]

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

7b) C program to prompt the user for the name of an environment variable and print its value if it is defined and a suitable message otherwise; and to repeat the process if user wants it.

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>

int main()
{
char env[10],*p;
int ch=1;

while(ch!=0)
{
printf(“n Enter name of evironment variable :”);
scanf(“%s”,env);

p=getenv(env);
printf(“%s”,p);
printf(“n Want to change ? 1 for yes & 0 for no :”);
scanf(“%d”,&ch);
}
return 0;
}

[Click Here to get other programs by email ]

Comments

  1. mspatel says:

    It is very nice to your programs in your site,Thanks for you.

  2. mspatel says:

    How to your programs in linux

  3. sandeephegde says:

    Dear mspatel,

    The programs will run on any Linux flavor like fedora.