View difference between Paste ID: wgmA7yyP and JjJR7fHA
SHOW: | | - or go back to the newest paste.
1
  1 #include <stdio.h>
2
  2 #include <stdlib.h>
3
  3 #include <unistd.h>
4
  4 #include <sys/types.h>
5
  5 #include <string.h>
6
  6 #include <inttypes.h>
7
  7
8-
  8 pid_t fork(void);
8+
9-
  9 pid_t getpid(void);
9+
10
 12 {
11
 13         int child_pid;
12
 14         int count = 0;
13
 16         int n = 0;
14
 17         int i;
15-
 15         int x = 0;
15+
 18         char bufor[1024], tmp[1024];
16
17
		sprintf(tmp, "%d ", getpid());
18-
 18         char bufor[4];
18+
		strcpy(bufor, argv[2]);
19-
 19
19+
		strcat(bufor, tmp);
20-
 20         //x = strtoimax(argv[1], NULL, 10);
20+
21-
 21         x = atoi(argv[1]);
21+
 21         n = atoi(argv[1]);
22-
 22         printf("Przed forem x = %i\n", x);
22+
23-
 23
23+
24-
 24         n = x;
24+
25-
 25         printf("n = %i\n", n);
25+
26-
 26
26+
27
 47                         //char* args[] = { argv[0], n - 1,  bufor,  NULL };
28-
 28                 printf("iteracja %i\n", i);
28+
29
 49                 }
30
 50         }
31
 51
32-
 32                         if (x >= 2){
32+
 52         for (i = 0; i < n; i++) {
33-
 33                                 x = x - 1;
33+
 53               int a;
34-
 34                                 sprintf(bufor, "%d", x);
34+
 54               wait(&a);
35-
 35                                 printf("x = %i\n", x);
35+
 55         }
36-
 36                                 printf("bufor = %s\n", bufor);
36+
37-
 37                                 printf("child_pid = %i\n", child_pid);
37+
 57         printf("Rodzic: %i\n", getppid());
38-
 38                         }
38+
 58         printf("Potomek: %i\n", getpid());
39-
 39                         /*
39+
40-
 40                         printf("x w for: %i\n", x);
40+