Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

c program to create directory using mkdir system call

+6 votes
asked Feb 15, 2023 by Parveen Dhaliwal (290 points)

2 Answers

0 votes
answered Feb 16, 2023 by Peter Minarik (86,580 points)

Check out the system() call. You can achieve your goal with this.

0 votes
answered Feb 21, 2023 by qwerty ytrewq (140 points)
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>

int main() {
    char* dirname = "mydirectory"; // Replace with desired directory name
    int result = mkdir(dirname, S_IRWXU | S_IRWXG | S_IRWXO); // Create directory with read, write, and execute permissions for owner, group, and others
    if (result == 0) {
        printf("Directory '%s' created successfully.\n", dirname);
    } else {
        printf("Error creating directory '%s'.\n", dirname);
    }
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...