Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<sys/types.h>
- #include<sys/stat.h>
- #include<fcntl.h>
- int main(int argc, char *argv[])
- {
- if(argc!=2)
- printf("usage : <exec> file dir.\n");
- char buffer[20];
- int nr_cifre=0;
- int file1=open(argv[1],O_RDONLY);
- int nr_caractere=0;
- while(read(file1,&buffer,sizeof(char)))
- {
- if(isdigit(buffer[0]))
- {
- nr_cifre++;
- printf("%c", buffer[0]);
- }
- nr_caractere++;
- }
- close(file1);
- printf("\n");
- printf("In fisierul dat ca argument sunt %d cifre.", nr_cifre);
- int pf = creat("/home/student/noulfisier", S_IRUSR|S_IWUSR);
- sprintf(buffer,"In fisierul dat ca argument sunt %d cifre.", nr_cifre);
- write(pf,buffer,strlen(buffer));
- struct stat s;
- int i=lstat(argv[1],&s);
- sprintf(buffer,"Grup ID: %d",s.st_gid);
- write(pf,buffer,strlen(buffer));
- symlink("home/student/noulfisier","./mylink");
- close(pf);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement