Jump to content

[Snippet]Enviroment Variables

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
Ok after i havent worked for a year now on C++ and i dont realy like c++ xD

and it has become a long time since my last post here i just want to share this small snippet ive just have done to display some enviroment variables.
You can modifie the project freely its nth special hope it gives you just an idea on how to use the getenv() function in c++

i wish you all a good night im sleep now.



#include <cstdlib>

#include <iostream>


using namespace std;


int main()

{

 // Declairing Variables

 

 char * GetEnviroment[10];

 

 //Associate Pointer Variable

GetEnviroment[0] = getenv("TMP");

GetEnviroment[1] = getenv("APPDATA");

GetEnviroment[2] = getenv("COMPUTERNAME"); 

GetEnviroment[3] = getenv("HOMEDRIVE"); 

GetEnviroment[4] = getenv("HOMEPATH");  

GetEnviroment[5] = getenv("OS");  

GetEnviroment[6] = getenv("PROCESSOR_ARCHITECTURE");  

GetEnviroment[7] = getenv("ProgramFiles");  

GetEnviroment[8] = getenv("USERNAME");  

GetEnviroment[9] = getenv("USERPROFILE");  

GetEnviroment[10] = getenv("windir");  


//Header Title

cout  << "Some of Current System Enviroment Variables" << "\n" << "********************************************" <<endl;


//Looping until we reach the last element of GetEnviroment

 for(int i = 0;i<10;i++)

 {

  cout  <<  GetEnviroment[i] << "\n" << "------------------------" << endl;

       }

 

system("PAUSE >> NULL");

return EXIT_SUCCESS;

}

Posted Image

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Long time no see, Kresh7. Thanks for the snippet!

#3
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
was woundering what you people are doing on the board xD thought let visit some old friends
Posted Image

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Good! :) You should come back more often. I don't suppose you guys will ever get your shirts now, though. I heard all mail was stopped over there in Kosovo.

#5
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
good post

Quote

some old friends
watch you language, im not old! im still 20
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#6
MathX

MathX

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,001 posts
Good little f**** up Kresh :P
Nice program, It's just I hate declaring arrays like that :A.

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!


#7
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
this is the way i do it mate xD but tell how would you have declaired the array or what dont u like on it ?
im open for suggetions
Posted Image

#8
MathX

MathX

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,001 posts
Do it your way m8. :)

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!