Xcode mkdir error?

Joined
Sep 10, 2011
Messages
3
Reaction score
0
Points
1
Ok so the command mkdir in c++ makes a directory. My problem is when i declare it in Xcode it declared it as a variable.
You normally use mkdir like this
mkdir "The File"; That creates a directory(folder)
But it gives me an error when I do that and says to type it like
mkdir; leaving out the whole point of making the directory. I need to make a folder to write save data to and read it so I need this to work! BTW if you don't know what library the command is in its in the sys/stat.h library.
 
Joined
Feb 25, 2009
Messages
2,112
Reaction score
71
Points
48
Your Mac's Specs
Late 2013 rMBP, i7, 750m gpu, OSX versions 10.9.3, 10.10
How exactly are you attempting to use mkdir?

Standard C for a function is not:

mkdir "The File";

as that line would never work. Plus, mkdir function takes two parameters, the path for the folder and the mode for the folder - not a single parameter.

I tested it with:

Code:
#include <stdio.h>
#include <sys/stat.h>

int main (int argc, const char * argv[])
{

    mkdir("MyFolder", S_IRWXU);
    return 0;
}
and it worked flawlessly using XCode.
 
Joined
Aug 21, 2011
Messages
36
Reaction score
0
Points
6
Your Mac's Specs
Late 2010 MacBook Pro 13 Inch
Like Nethfel said be sure you are using it correctly. Also, and this may sound stupid, be sure it is a cpp file. Unless you are using it with an app that uses different files (such as C, Objective-c etc.) I would just build it up from the ground in a command line tool. At least that way you have a cpp file set up. :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top