Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > getcwd changes? how can I get current path?

Reply
Thread Tools

getcwd changes? how can I get current path?

 
 
Jona
Guest
Posts: n/a
 
      05-23-2007
Issue:
*Get the path location of my executable.

Semi Fix..
*Using getcwd() or plainly giving no path would also do the job...
say reading a file...

*The problem is when I call other functions like...
CreateDirectory("foo",NULL)
it changes my default directory to \foo folder...
so when I call getcwd() or simply don't give a path to access a file,
now the default folder is foo ....
Any Idea why this happens? how can it be defaulted back to its
original path?

is there a better way to do this?

thanks,
Jonathan

 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      05-24-2007
On 23 May 2007 13:51:52 -0700, Jona <> wrote
in comp.lang.c++:

> Issue:
> *Get the path location of my executable.


The standard C++ language does not define the operation of file
systems, because different operating systems implement them very
differently. So the C++ language has no concept of path, nor any
functions that deal with it.

The first string in the second argument to main, conventionally called
argv[0], might contain the full path of your executable, depending on
your operating system, or it might not.

> Semi Fix..
> *Using getcwd() or plainly giving no path would also do the job...
> say reading a file...


There is no function "getcwd()" in the standard C++ library. If your
platform provides such a function, it is an extension and your
compiler and platform define it, not the C++ language.

> *The problem is when I call other functions like...
> CreateDirectory("foo",NULL)
> it changes my default directory to \foo folder...
> so when I call getcwd() or simply don't give a path to access a file,
> now the default folder is foo ....
> Any Idea why this happens? how can it be defaulted back to its
> original path?
>
> is there a better way to do this?


You need to ask in a platform specific newsgroup. In your case,
news:comp.os.ms-windows.programmer.win32 is a good one.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Expected bahaviour of os.chroot and os.getcwd r0g Python 3 09-14-2010 01:11 PM
in ``': No such file or directory - getcwd (Errno::ENOENT) amos Ruby 1 01-22-2007 07:14 PM
Trouble with the encoding of os.getcwd() in Korean Windows Erik Bethke Python 7 02-09-2005 05:11 PM
Too many open files - getcwd (Errno::EMFILE) sera@fhwang.net Ruby 2 02-04-2005 10:49 PM



Advertisments