C program to create a directory using mkdir() function
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Input the name (path) of the directory, and then we will create the given directory using the mkdir() function.
The mkdir() function is library function of <sys/stat.h> header file which is used to create a new directory with a new path.
Syntax:
The argument path defines the path of the directory, and the mode specifies the file permissions for the new directory file.
The function returns 0 if the directory created successfully, or -1 on failure.
Program:
The source code to create a directory using the mkdir() function is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
Output:
Explanation:
Here, we created a character array dirName. Then we read the name of the directory from the user. Then we created the given directory using the mkdir() function and printed the appropriate message on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer