find home path of C Environment

This is a discussion on find home path of C Environment within the C Programming forums, part of the General Programming Boards category; Hey, is there a function/call in c in windows to find the place from where your C-Development Environment is running. ...

  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,311
    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%.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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, 07:55 AM
  2. Retrieving PATH Environment Variable
    By mercury529 in forum Windows Programming
    Replies: 9
    Last Post: 01-09-2007, 07: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21