getting the drive letter(or path)?

Started by
5 comments, last by homeboye 18 years ago
Hello! I'd like to know if there is a function in C/C++ that return the drive letter(or the path) of where the command is ran. It can also be a windows command, or w/e. ty.
Advertisement
Sorry if I'm misinterpreting you but if you mean the drive letter of where your program is run, it is the first character of the first command line arguement to main or WinMain.

Otherwise, is getcwd in dir.h standard C? Seems to be available on all the compilers I've ever seen and returns the current directory.
ok, found it, tnx!

now i'd like to know how to convert from int to char so this would work:
char dest[50];int source;strcat(dest,source);
Hi,
you should really check the stickies in the General and For Beginners forums (where this really belongs).

Noteworthy threads, articles and other resources

Read through the C++ section and come back when you don't understand something and couldn't help yourself through google.

Note that C++ isn't C, and working with char arrays in C++ like you do in C is insecure and error-prone. (This note will come up often in the forums if you post with a subject suggesting C++ and then following with some C-ish code)

For starters, you could google 'std::string' and 'std::stringstream' (these help you with conversions) and 'C++ iostreams' in general (confusing stuff, but IF you want to learn C++, there's no way around it).

The C++ FAQ lite helps with many beginners and expert questions.
Also, there is the STI SGL docs to help you with standard libary issues.
MSDN comes in useful, too.
in short, i should use string.
well.. are there any C functions where i can append strings/chars?
o_O

Perhaps you care to read through my post... and click the links in it
no need, i figure it out.
tnx!

This topic is closed to new replies.

Advertisement