HOMEDIR, USERNAME, COMPUTER variables...

Discussion in 'C++' started by HardHackz@gmail.com, Mar 1, 2007.

  1. Guest

    Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
    has for C++?
     
    , Mar 1, 2007
    #1
    1. Advertising

  2. Lionel B Guest

    On Thu, 01 Mar 2007 04:44:12 -0800, HardHackz wrote:

    > 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++...

    --
    Lionel B
     
    Lionel B, Mar 1, 2007
    #2
    1. Advertising

  3. Lionel B wrote:
    > On Thu, 01 Mar 2007 04:44:12 -0800, HardHackz wrote:
    >
    >> 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++...


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

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Mar 1, 2007
    #3
  4. Marcus Kwok Guest

    Victor Bazarov <> wrote:
    > Lionel B wrote:
    >> On Thu, 01 Mar 2007 04:44:12 -0800, HardHackz wrote:
    >>
    >>> 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++...

    >
    > 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;
    }

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply
     
    Marcus Kwok, Mar 1, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. EMW

    Username on client computer

    EMW, Jun 20, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,473
  2. jason via DotNetMonster.com

    computer username display

    jason via DotNetMonster.com, Jul 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,438
    Aaron Corcoran
    Jul 7, 2005
  3. ecu_jon

    homedir, file copy

    ecu_jon, Jan 30, 2011, in forum: Python
    Replies:
    14
    Views:
    591
    Dave Angel
    Jan 31, 2011
  4. Shailesh Patel
    Replies:
    0
    Views:
    476
    Shailesh Patel
    Nov 8, 2006
  5. Florent 'flure' C.

    How to get homedir ?

    Florent 'flure' C., Apr 29, 2004, in forum: Ruby
    Replies:
    2
    Views:
    112
    Sascha Doerdelmann
    Apr 29, 2004
Loading...

Share This Page