Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: What is environment and how do I get environment for a specific entry?

Answer: While working in DOS, it stores information in a memory region called environment. In this region we can place configuration settings such as command path, system prompt, etc. Sometimes in a program we need to access the information contained in environment. The function getenv( ) can be used when we want to access environment for a specific entry. Following program demonstrates the use of this function.
#include <stdio.h>
#include <stdlib.h>

main( )
{
char *path = NULL ;

path = getenv ( "PATH" ) ;
if ( *path != NULL )
printf ( "nPath: %s", path ) ;
else
printf ( "nPath is not set" ) ;
}

Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook