HOMEDIR, USERNAME, COMPUTER variables...

H

HardHackz

Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
has for C++?
 
L

Lionel B

Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
has for C++?

No. That's all system-dependent. C++ doesn't assume that things like
"user" or "directory" even exist (although it does have a notion of
"file"). Think about it: a microchip controlling your fridge might be
programmed in C++...
 
V

Victor Bazarov

Lionel said:
No. That's all system-dependent. C++ doesn't assume that things like
"user" or "directory" even exist (although it does have a notion of
"file"). Think about it: a microchip controlling your fridge might be
programmed in C++...

Not sure what is meant by 'variables like batch has', but if those
are "environment" variables, see 'getenv' function.

V
 
M

Marcus Kwok

Victor Bazarov said:
Not sure what is meant by 'variables like batch has', but if those
are "environment" variables, see 'getenv' function.

Also, your implementation may provide a signature for main() like:

int main(int argc, char* argv[], char* envp[])

where envp is an array of C-style strings representing the current
environment.

See if this works on your implementation:


#include <iostream>

int main(int argc, char* argv[], char* envp[])
{
using std::cout;

for (int i = 0; envp != 0; ++i) {
cout << envp << '\n';
}

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top