Re: [Dev-C++] rookie question... Getting the current directory
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Brenden T. <br...@rc...> - 2002-12-26 21:15:14
|
Try getcwd():
/#include/ /<unistd.h>/
/#include/ /<io.h> // <stdio.h> is standard but MinGW uses io.h/
/main()/
/{/
/char/ /*cwd;/
/if/ /((cwd/ /=/ /getcwd(NULL,/ /64))/ /==/ /NULL)/
/{/
/perror("pwd");/
/exit(2) <http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?exit+2>;/
/}/
/(void)printf("%s\n",/ /cwd);/
/free(cwd);/
/return(0);/
/}/
The man page is at:
http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?getcwd+3
Note that this is POSIX, Windows has their own non-portable API for
directory and file operations.
Good luck!
Danny Roelofs wrote:
> Hi,
>
> Just started today picking my programming hobby after 10 years when i
> used an amiga and a whole different programming
> enviroment, i feel like a rookie again in the world of programming
> with c++ with dev4 & windows.....
>
> Can someone tell me how to get the current directory, i think it would
> be something like this:
>
> string test;
>
> void main(void)
> {
>
> test = GetCurrentDir();
>
>
>
> return 0;
> }
>
> But ofcourse, this doesnt work.... someone.. enlighten me..
>
> i tryed all kinds of material but couldn't find something that worked
> with dev4 and i dont know where i have to find the problem.
>
> thanks for your help
>
> Danny.
>
>
|