1 #include <stdio.h> 2 #include <string.h> 3 #include <unistd.h> 4 5 void write_int_(int fd, int n) { 6 if (n > 0) { 7 write_int_(fd, n / 10); 8 9 int rem = n % 10; 10 char c = '0' + rem; 11 write(fd, &c, 1); 12 } 13 } 14 15 void write_int(int fd, int n) { 16 if (n == 0) { 17 write(fd, "0", 1); 18 } else { 19 if (n < 0) { 20 write(fd, "-", 1); 21 write_int_(fd, -n); 22 } else { 23 write_int_(fd, n); 24 } 25 } 26 } 27 28 void stderr_int(int n) { 29 write_int(2, n); 30 write(2, "\n", 1); 31 } 32 33 int main(int argc, const char **argv) { 34 char *str = "Hello, World!\n"; 35 for (int i = 0; str[i]; ++i) { 36 putchar(str[i]); 37 } 38 return 0; 39 } 40