/* a sample program that change the mode of a file */
#include <stdio.h>
#include <sys/stat.h>

int main() {
    char filename[80];
    char *name;
 
    if((name = tmpnam(NULL)) == NULL) {
        printf("temp file name could not be made. \n");
        exit(1);
    }
    creat(name, 100);
    /* read, write, execute permission: owner 
       read, write permission: group 
       read, write permission: other */
    if(chmod(name,0755)!=0)
       perror("can not change the mode of specified file\n");
    else
       printf("The mode of file '%s' has been changed.\n", name);
}
