Jump to content
  • Advertisement
Sign in to follow this  

getting the drive letter(or path)?

This topic is 4436 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!