#include <fcntl.h>
      #include <stdio.h>
      #include <stdlib.h>
      
      int rm() {
      	int fd;
      	if (argc != 2) {
      		printf("Number of Arguements provided != 2 \n");
      		printf("Arguements Required: \n");
      		printf("Filename \n");
      		exit(-1);
      	}
      	fd = open(argv[1], O_RDONLY);
      	if (fd != -1) {
      		close(fd);
      		unlink(argv[1]);
      		printf("%s deleted! \n", argv[1]);
      	}
      	else {
      		perror(argv[1]);
      	}
      	return 0;
      }
      
      C language logo

      rm simulation

      Codiga's C Recipes

      Simulate the rm command

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.