Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- int main(int argc, char *argv[]){
- if(argc != 3)
- printf("Usage file dir");
- int a;
- int b;
- char buff[20];
- a = open(argv[1], O_RDONLY, S_IWUSR | S_IRUSR);
- size_t nbytes;
- nbytes = sizeof(buff);
- if(read(a, buff, nbytes) == -1)
- printf("***eroare****");
- char dir[20];
- strcpy(dir,argv[2]);
- strcat(dir,"/");
- strcat(dir,argv[1]);
- b = open(dir, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
- mkdir(dir, S_IRUSR | S_IWUSR | S_IXUSR);
- int ibuff;
- char wrbuff[20];
- int i=0,j=0;
- while(i<sizeof(buff)){
- if(isdigit(buff[i])){
- ibuff=buff[i]-'0';
- if(ibuff % 2 == 0){
- wrbuff[j]=buff[i];
- j++;
- }
- }
- i++;
- }
- i=0;
- while(wrbuff[i])
- i++;
- printf("%s",wrbuff);
- if(write(b, wrbuff, 3) == -1)
- printf("***eroare***");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement