Advertisement
Guest User

creat.c

a guest
Mar 28th, 2020
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7. int main(void){
  8.     char *fname = "a.txt";
  9.     int f = creat(fname,0755);
  10.     if( f == -1 ){
  11.         fprintf(stderr,"Can't creat '%s'",fname);
  12.         exit(1);
  13.     }
  14.     printf("'%s' created: %d\n", fname, f);
  15.     close(f);
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement