Thread: find home path of C Environment

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    18

    find home path of C Environment

    Hey, is there a function/call in c in windows to find the place from where your C-Development Environment is running.
    For example, (in case of Turbo-c), MOSTLY it is
    C:\TC\bin.
    Can i find this from within the program and output to a string or something ???

  2. #2
    Registered User
    Join Date
    Mar 2010
    Location
    China
    Posts
    74
    Under linux, you can use getenv() in stdlib.h to retrieve the environment variable "HOME". But I don't know whether it works under windows.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Generally, no.

    Turbo C does not. Other than a couple of macros to identify you are using a Turbo (or Borland) compiler, and version number, there doesn't tend to be a way to retrieve detailed information about the installation (for example, installation directory).

    Some other compilers provide predefined macros (or similar - the words may vary) that can be used to identify the compiler and installation details. If your compiler supports such features, it will be listed in the documentation for your compiler.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Also, even finding out can do more harm than good; knowing that your IDE is running in some particular location means nothing about where your program is going to be running from (the whole point is that programs are separate beasts, and aren't run from the IDE, right?) -- so unless your question is "my program works when I run it from the IDE, but not when I run it from the command-line/double-clicking, and I want to know what path the IDE uses when it runs my program" then you probably just don't want to know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-22-2010, 08:55 AM
  2. Retrieving PATH Environment Variable
    By mercury529 in forum Windows Programming
    Replies: 9
    Last Post: 01-09-2007, 08:02 PM
  3. Setting path environment variable
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 09-01-2006, 03:03 PM
  4. Accessing the 'home' directory path?
    By smoothdogg00 in forum C Programming
    Replies: 3
    Last Post: 04-30-2006, 10:51 AM
  5. Path / Environment in unix
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 04:52 AM