Today, we are going to share a C program to print environment variables. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to print environment variables with the output.
We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.
1 2 3 4 5 6 7 8 9 10 11 | #include <stdio.h> void main(int argc, char *argv[], char * envp[]) { int i; for (i = 0; envp[i] != NULL; i++) { printf("\n%s", envp[i]); } } |
SUDO_GID=0
MAIL=/var/mail/root
USER=root
SHLVL=1
HOME=/root
OLDPWD=/
SUDO_UID=0
LOGNAME=root
_=/usr/local/bin/forever
TERM=xterm-color
USERNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
LANG=en_US.UTF-8
SUDO_COMMAND=/bin/bash /opt/fwm/start.sh
SHELL=/bin/bash
SUDO_USER=root
PWD=/home
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.