Jump to content
  • Advertisement
Sign in to follow this  
Mr_Ridd

C++ Current Directory

This topic is 5090 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

Hey How do I get the current directory I'm working in, in C++? I've seen a function called getcurdir() or something like that, which is found in dir.h. I've using Visual Stuio 6 and there is no dir.h? Is there another way to get it? Thanks

Share this post


Link to post
Share on other sites
Advertisement
just use GetModuleFileName from the win32 API

something like:

char lpFilename[255];
memset( lpFilename, 0, 255 );
GetModuleFileName( AfxGetInstanceHandle(),lpFilename, MAX_PATH );

should do it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There is getcwd(buffer,size) in direct.h (win32) or unistd.h (unix)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Current working directory and application paths are not always the same.

Share this post


Link to post
Share on other sites
Thanks

-----
a2ps

Do I have to include anything to use those functions?

------
Anonymous Poster

It says in the reference that direct.h includes dir.h. I don't have dir.h though?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!