How to change current working directory in c/c++?
-
Hello everybody, I am trying to change working directory in c++, For example: My programs is in c://work, I run the program from there, but during running this program, I have to change working directory, do something there.I tried to do it like this:
system("cd c:/work/test");
but it does not change working directory Is there a way to change current working directory in c/c++? Thanks in advance
It is never late to learn
-
Hello everybody, I am trying to change working directory in c++, For example: My programs is in c://work, I run the program from there, but during running this program, I have to change working directory, do something there.I tried to do it like this:
system("cd c:/work/test");
but it does not change working directory Is there a way to change current working directory in c/c++? Thanks in advance
It is never late to learn
chdir is the function you should use. as for what you tried it works in the sense that cmd.exe which is started as a child process whenever you call system() changes its working directory.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
chdir is the function you should use. as for what you tried it works in the sense that cmd.exe which is started as a child process whenever you call system() changes its working directory.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
chdir is c/c++ function? or shell function? can i use it like
system("chdir c:/work/test");
It is never late to learn
-
Hello everybody, I am trying to change working directory in c++, For example: My programs is in c://work, I run the program from there, but during running this program, I have to change working directory, do something there.I tried to do it like this:
system("cd c:/work/test");
but it does not change working directory Is there a way to change current working directory in c/c++? Thanks in advance
It is never late to learn
_chdir
[^].SetCurrentDirectory
[^]. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
chdir is c/c++ function? or shell function? can i use it like
system("chdir c:/work/test");
It is never late to learn
Gofur Halmurat wrote:
can i use it like system("chdir c:/work/test");
Yes, with the same result you got before. :rolleyes: :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
_chdir
[^].SetCurrentDirectory
[^]. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Actually, I am using GNU c compiler for UNIX, it seems chdir and SetCurrentDirectory for windows only, is there any other way for UNIX?
It is never late to learn
-
Actually, I am using GNU c compiler for UNIX, it seems chdir and SetCurrentDirectory for windows only, is there any other way for UNIX?
It is never late to learn
Gofur Halmurat wrote:
I am using GNU c compiler for UNIX
GNU
isn't forLinux
(after all "G
nu isN
otU
nix" )?Gofur Halmurat wrote:
it seems chdir and SetCurrentDirectory for windows only, is there any other way for UNIX?
chdir
should be available on anyPOSIX
compliant system, likeGNU/Linux
. Are you aware thatCodeProject
has aLinux
forum?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Actually, I am using GNU c compiler for UNIX, it seems chdir and SetCurrentDirectory for windows only, is there any other way for UNIX?
It is never late to learn
Did you use if these functions and what was result?