Skip to content

Commit 1ff8341

Browse files
mkdir.cpp
1 parent 5315694 commit 1ff8341

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mkdir.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <sys/types.h>
2+
#include <sys/stat.h>
3+
#include <unistd.h>
4+
5+
//https://stackoverflow.com/questions/7430248/creating-a-new-directory-in-c
6+
7+
int main(){
8+
struct stat st = {0};
9+
10+
if (stat("newdir", &st) == -1) { //checking if the directory exists
11+
mkdir("newdir", 0700);
12+
}
13+
}

0 commit comments

Comments
 (0)