Dec 21, 2011 at 4:42am Dec 21, 2011 at 4:42am UTC
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.
Dec 21, 2011 at 1:27pm Dec 21, 2011 at 1:27pm UTC
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())
Dec 23, 2011 at 7:46pm Dec 23, 2011 at 7:46pm UTC
i do that and it compiles just fine but it wont do the system("ls") so i dont know if it is working
Dec 23, 2011 at 8:00pm Dec 23, 2011 at 8:00pm UTC
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.
Dec 25, 2011 at 7:29am Dec 25, 2011 at 7:29am UTC
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 Dec 25, 2011 at 7:33am Dec 25, 2011 at 7:33am UTC