detectine OS type?
For my little program to run, it needs to open a file, read the contents then display it. easy yes...
However I need to hardcode this path of the file in.
But the location of the file is different from OS to OS, I want it to work in Linux primarily, however I need to find a way of detecting for Mac OS X??
Is there a little function I can call that will determine the OS type?
or is there a way I can make a function?
Either do it at compile time, or run time.
The first is easiest. All you have to do is check for macros that your compiler should define and specify your paths. i.e.
Of course, gcc on OS X should define something like MAC -- but check the manual.
const char * prefix = "/example/path/";
const char * prefix = "/some path for mac";
Or if you wanted to do it at runtime, use getenv().
Originally Posted by zacs7
(should be in all caps. Dunno why but the forum changes it to small letters for me o_O)
got it working great :D