
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C program to print environment variables
Here, we will create a c program to print environment variables.
Environment variable is a global variable that can affect the way the running process will behave on the system.
Program to print environment variables
//Program to print environment variables
Example
#include <stdio.h> int main(int argc, char *argv[], char * envp[]){ int i; for (i = 0; envp[i] != NULL; i++) printf("
%s", envp[i]); getchar(); return 0; }
Output
ALLUSERSPROFILE=C:\ProgramData CommonProgramFiles=C:\Program Files\Common Files HOMEDRIVE=C: NUMBER_OF_PROCESSORS=2 OS=Windows_NT PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER=x86 Family 6 Model 42 Stepping 7, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=2a07 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files PUBLIC=C:\Users\Public SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\Windows WATCOM=C:\watcom windir=C:\Windows
- Related Articles
- Golang program to print struct variables
- Python Environment Variables
- MySQL Environment Variables
- Golang Environment Variables
- C# Program to Get and Print the Command Line Arguments Using Environment Class
- Perl CGI Environment Variables
- How to Set environment variables using PowerShell?
- How to Use Environment Variables in Postman?
- CGI Environment Variables in Python
- Managing Environment Variables in Linux
- Locale Environment Variables in Linux
- Setting MySQL Environment Variables on Linux
- How do I pass environment variables to Docker containers?
- Retrieve environment variables with Java Map Collection
- Load Environment Variables in a Cron Job

Advertisements