I am working on a project that involves a bit of directory manipulation. Until now i only had to create create directories as per user input, so till now the commnad mkdir worked fine:

But now i have to do some manipulations on the string to get the path.I have run into this problem where mkdir is not crating the directories when i pass a string variable as argumnet.
//str=(assigned something after manipulations);

Is there another way i can do this??

Thank you!

its not working. gives me the following error

request for member `c_str' in something not a structure or union

Oop. Sorry; my fault! I saw you mention a string and forgot this was C land - I'm so used to a string being a C++ string object and nowadays I never use the term in C.

Can you give some sample code that doesn't work?

Edited 3 Years Ago by Moschops

Another hint: mkdir() only works on one directory at a time. You have to call mkdir() for each new directory in the directory hierarcy. If you want to create a directory "c:\one\two\three" then call mkdir("c:\one"), mkdir("c:\one\two") and finally mkdir("c:\one\two\three")

Edited 3 Years Ago by Ancient Dragon

Thanks a lot Ancient Dragon. i was trying to create 3 directories at a time. Had to split it up with a for loop to make 1 directory at a time.

Thank you for the inputs, Moschops.

Yes, like this: mkdir("c:\\one\\two\\three"). (you actully need four of them to post here because the editor removes two of them. That is escaping the escape character \)

Edited 3 Years Ago by Ancient Dragon

/ worked fine for me actually.

Because / is not a backslash. \ is a backslash.

/ is far more portable and as a general rule is preferable to using \\

This question has already been answered. Start a new discussion instead.