Preview:
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h> 

int main() {
    const char *filename = "example.txt";
    mode_t mode = 0644; 
    
    if (chmod(filename, mode) == -1) {
        perror("chmod");
        exit(EXIT_FAILURE);
    }
    
    printf("File permission successfully changed\n");
    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter