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 ???

Dani AI

Generated

There is no portable C function that will tell a running program “where the IDE is installed.” An executable only knows about its own runtime context (where the exe lives, the current working directory, environment it was launched under). If the goal is to determine the IDE install directory (for example your Turbo‑C folder), that information must be supplied somehow — it is not automatically embedded in every compiled binary.

If what you actually need is the location of the running program on Windows, use the Win32 API to get the executable path at runtime. Example:

#include <windows.h>
#include <stdio.h>

int main(void) {
    char path[MAX_PATH];
    if (GetModuleFileNameA(NULL, path, sizeof(path)) != 0) {
        printf("Executable path: %s\n", path);
    }
    return 0;
}

If you need the IDE installation path itself, the reliable approaches are build-time or configuration-time: have the IDE or build script write the path into a header, or pass it as a compile-time macro or environment variable the program can read. Minimal example of using a build-time macro inside code:

#ifndef IDE_HOME
#define IDE_HOME "UNKNOWN"
#endif

printf("IDE home: %s\n", IDE_HOME);

Advanced, platform-specific workarounds (more fragile): enumerate running processes and inspect an IDE process image path, or consult system installer data — both are Windows-specific and brittle. Note also that older tools like Turbo C are often run under emulation on modern systems, so host paths may not map directly. As and pointed out, make your question focused in one place; for pick the method that matches the real need (exe path vs IDE install path) and supply that context when asking for code.

Recommended Answers

All 4 Replies

http://cboard.cprogramming.com/c-programming/139292-find-home-path-c-environment.html
Suggest sticking to asking on one forum at once.
http://www.catb.org/~esr/faqs/smart-questions.html#forum
or
http://www.catb.org/~esr/faqs/smart-questions.html#urgent

i dont get that sir,
by posting in a couple of forums, I belive, I am not only improving my understanding but also helping people from other forums address the issue. For eg, before posting i normally look up the previous posts on the forum, so it helps me if i can find a topic on my forum.
For example , i got a couple of responses from the other forum which i found far more useful than the 2 out-of-context links u sent me.
And if u find this on another forum, why do you go ahead and click it unless you think you can get something useful out of it. I am sure you would have read the responses from the other forum as well. So how can you do it, after telling me not to do it.
All cool from my side, but still dont agree with your view :)

commented: You're obviously so full of your own self importance that you don't care how much time you waste for other people -4

Tubby, Salem is one of the most prolific C repliers on the C forums. What he's talking about is that people post the same info on several boards. Then people like him answer them, ON EACH OF THE SEVERAL BOARDS.

That means there's a tremendous amount of duplicated work, especially when the original poster has a boatload of follow up questions.

We've seen where the answers were 2-3 pages deep, on 4 forums. The problem is, people do this as a donation to the community, but there is limited time available. Multiple forum requests (I'm referring to those made on the same day, with the same content), waste that resource.

Sorry, but I do not love doing string processing in C. You could do manual PATH processing or find library to support that for you in C. Or you could find way to retrieve it from System Registry (with winreg.h).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.