Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create directories using the C standard library (or otherwise)?

Tags:

c

file-io

Help appreciated. Couldn't find any mention of this in "the book" (k&r).

like image 335
aviraldg Avatar asked Oct 31 '25 08:10

aviraldg


2 Answers

By calling the mkdir() function. That links to the manual page online. To get that page on your (Linux) machine, enter in a terminal:

$ man 2 mkdir

The '2' is important, and is called the manual page section number. Since you want help for the C function "mkdir", as opposed to the command-line command "mkdir", you need to specify the section as otherwise you will get the command by default.

like image 139
unwind Avatar answered Nov 02 '25 00:11

unwind


Although not part of the standard library, most implementations do include mkdir():

#include <dir.h>
...
mkdir("directory");
like image 44
Andre Miller Avatar answered Nov 01 '25 23:11

Andre Miller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!