Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ Current Working Directory

Started by Tonic151 Oct 10, 2002 at 2:41 PM 2 replies 850+ views
Original Post
Tonic151
Tonic151
Well since the search is disable I was wondering if someone could give me the specifics on what headers i need and the function calls for getting the Current Working directory for Both Windows and Linux. Would be very much apprecieated. Using g++ Devc++ 5 in Windows, and g++ 2.95.3 in Linux Thanks! [edited by - tonic151 on October 10, 2002 3:51:40 PM]
Brian Jones
Brian Jones
I don''t know about Linux, but there is a Win32 API function -

GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer);

nBufferLength is the amount of elements in lpBuffer.
I don't have a signature
mrhollow
mrhollow
In linux you would use:

#include <unistd.h>

char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);

Depending on what you want.

I suspect that since you are using DevC++ (g++ or mingw32) in windows, these functions should be available to you. The only problems I''ve had so far in writing cross compatible code for windows and linux comes in when trying to get code to compile in MSVC...

Cheerio,
Aaron

| HollowWorks.com | Rhott.com |
Tonic151
Tonic151
Thanks a lot guys.. not to worried about MSVC.. M$ can go bite a bone.. i also found getcwd() in io.h for Devc++ and hopefully it will be the same in linux too.. if not i''ll try that one you gave me for linux.. Thanks!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.