Skip to content

Instantly share code, notes, and snippets.

@morganp
Created June 16, 2014 13:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morganp/87b918574200a244ef49 to your computer and use it in GitHub Desktop.
Save morganp/87b918574200a244ef49 to your computer and use it in GitHub Desktop.
Folder creation with C (mkdir)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
//## include <sys/stat.h> required for mkdir
// gcc c_mkdir_example.c -o c_mkdir_example
// c_mkdir_example
// ls -l
main () {
mkdir("Test_0777", 0777);
//drwxrwsr-x 2 morganp morganp 4.0K Jun 16 18:10 Test_0777/
mkdir("Test_777", 777);
//dr----s--t 2 morganp morganp 4.0K Jun 16 18:10 Test_777
}
@morganp
Copy link
Author

morganp commented Jun 16, 2014

The leading '0' is very important in the file mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment