I would like to know how global variables differ from environment variables or is it the same thing?

  • What programming language? - Streletz
  • can I find out what language I am talking about? - Air
  • one
    global called variables within the programming language itself, accessible from all places of the program. And environment variables are special operating system variables for receiving information from outside the program - Mike
  • @Streletz yes in principle - Pavel Igorev

1 answer 1

These are different entities.

Environment variables / environment variables are certain text variables created by the OS and storing information about system settings.

In Windows / Unix, their list can be viewed by typing from the console:

set

Example:

HOME=/home/vivek vivek@nas01:~$ env TERM=xterm-256color SHELL=/bin/bash XDG_SESSION_COOKIE=9ee90112ba2cb349f07bfe2f00002e46-1381581541.324726-906214463 SSH_CLIENT=192.168.1.6 60190 22 SSH_TTY=/dev/pts/1 USER=vivek MAIL=/var/mail/vivek PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games PWD=/home/vivek LANG=en_IN SHLVL=1 HOME=/home/vivek LANGUAGE=en_IN:en LOGNAME=vivek SSH_CONNECTION=192.168.1.6 60190 192.168.1.10 22 _=/usr/bin/env 

Global variables are a completely different story:

In programming, a global variable is a variable whose scope is the entire program.