chdir with varibles

sup yall. working on this program that will make a directory and change to it
I know how to change a directory or make one with static values but i wnat it to work with variables like


chdir(varible)
unfortunate this does not work so i don't know what to do.
If varible is a char* it should work. If varible is a std::string you have to use the c_str() function to get a char* from it. chdir(varible.c_str())
i do that and it compiles just fine but it wont do the system("ls") so i dont know if it is working
The system() call returns an integer. What value is it returning? If it's -1, then display the value of errno to see what the problem is.
TBH, you probably selected the wrong language. You should be writing a shell script instead.
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Check the returned value. That is how you know if it was succesful (or use get_current_dir_name)
¿what do you want to do?

@Athar: ¿Don't you think that is a little premature?
Last edited on
Topic archived. No new replies allowed.