Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <fcntl.h>
- #include <string.h>
- int main() {
- const char* initialnew = "./polygon/a";
- int lennew = (int) strlen(initialnew);
- char new[lennew + 3];
- new[0] = 0;
- strcat(new, initialnew);
- const char* initialold = "./a";
- int lenold = (int) strlen(initialold);
- char old[lenold + 3];
- old[0] = 0;
- strcat(old, initialold);
- int i = 0;
- while (i < 100) {
- sprintf(old + lenold, "%02d", i);
- sprintf(new + lennew, "%02d", i + 1);
- printf("%s %s\n", old, new);
- if (symlink(old, new) < 0) {
- printf("Error\n");
- exit(-1);
- }
- int fd = open(new, O_RDONLY);
- if (fd < 0)
- break;
- else if (close(fd) < 0) {
- printf("Error2\n");
- exit(-1);
- }
- ++i;
- }
- printf("%d\n", i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement