Created
February 4, 2012 15:26
-
-
Save PhDP/1738481 to your computer and use it in GitHub Desktop.
Create a directory in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc main.c -o main | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
int main() | |
{ | |
mkdir("newdir", S_IRWXU); // S_IRWXU is the mode, it gives read/write/search access to the user. | |
FILE *out = fopen("newdir/newfile.txt", "w"); | |
fprintf(out, "Hello new directory!\n"); | |
fclose(out); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment