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("Trebuie sa dati un argument pt fisierul de citire");
- exit(420);
- }
- char buffer[20];
- int nrc = 0;
- int fisier = open(argv[1], O_RDONLY);
- int nrch = 0;
- while(read(fisier, &buffer, sizeof(char))){
- if(isdigit(buffer[0])){
- nrc++;
- printf("%c", buffer[0]);
- }
- nrch++;
- }
- close(fisier);
- printf("\n");
- printf("In fisierul dat ca argument sunt %d cifre.", nrc);
- int pf = creat("home/student/kate/nou", S_IRUSR|S_IWUSR);
- sprintf(buffer, "In fisierul dat ca argument sunt %d cifre.", nrc);
- 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/kate/nou", "./mylink");
- close(pf);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement