473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

getcwd changes? how can I get current path?

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

May 23 '07 #1
1 8360
On 23 May 2007 13:51:52 -0700, Jona <me***********@hotmail.comwrote
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
May 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Erik Bethke | last post by:
Hello All, I have found much help in the google archives but I am still stuck... here is my code snippet: path = os.getcwd() path = path.decode('UTF8') Now the trouble is I am getting that...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
2
by: Greg Allen | last post by:
I know this has been discussed before, and have found some documentation about it on the web. But nothing has fixed my problem. I am running the 1.1 .NET framework, SP1. I have a web...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
1
by: Avi | last post by:
Hi All, I am using following function to copy a file. System.IO.File.Copy(sourcefile,destFile); I am giving absolute path in destFile. (eg. "C:\avi.txt") After execution of this call, my...
3
by: Rymfax | last post by:
Hello, I was hoping someone could help me with a problem I'm having. I've got a C# app that uses several DLL Imports from setupapi.dll and others (Thanks again for the Help on those Willy). One...
1
Xx r3negade
by: Xx r3negade | last post by:
Hi. I have a script located in /home/jBrandt/Code/python/ftest.py. When I print the results of os.getcwd(), however, it gives me /home/jBrandt/Code as the current working directory. I realize that...
3
by: melbourno | last post by:
I have a Perl script that I run and the out come as showing below: Log chain 1: Reading: server 2\08120700.mls Reading: server 2\08120900.mls Reading: server 1\08121100.mls Log chain 2: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.