4.lika.18_test.coder 4.ilyaz.18_test.coder

--- 4.lika.18_test.coder.fmt.c	2020-06-08 11:39:11.766116013 +0300
+++ 4.ilyaz.18_test.coder.fmt.c	2020-06-08 11:39:11.742115753 +0300
@@ -1,27 +1,25 @@
 #1 "<stdin>"
 #include <stdio.h>
+#include <sys/types.h>
 #include <signal.h>
+#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
 int main(int argc, char *argv[]) {
-    int i = 0;
-    while (1) {
-	char a = argv[2][i];
-	char b = argv[2][i];
-	for (int j = 7; j >= 0; j--) {
-	    int x = (a >> (j)) & 0x1;
-	    if (x == 1)
-		kill(atoi(argv[1]), SIGUSR2);
+    char *c = argv[2];
+    int pid;
+    sscanf(argv[1], "%d", &pid);
+    int len = strlen(c) + 1;
+    *(c + len) = '\0';
+    for (int i = 0; i < len; ++i) {
+	for (int j = 7; j >= 0; --j) {
+	    int byte = (c[i] >> j) & 1;
+	    if (byte == 1)
+		kill(pid, SIGUSR2);
 	    else
-		kill(atoi(argv[1]), SIGUSR1);
+		kill(pid, SIGUSR1);
 	    usleep(1000);
 	}
-	if (b == 0)
-	    break;
-	i++;
     }
     return 0;
 }