learning-cc4e

Solution to https://cc4e.com/. If you copy these you're not right in the head.
git clone https://kaka.farm/~git/learning-cc4e
Log | Files | Refs

main.c (523B)


      1 #include <stdio.h>
      2 #include <string.h>
      3 int main() {
      4   char t[1000];
      5   char *copy();
      6   void reverse();
      7   copy("Hello world", t);
      8   printf("%s\n", t);
      9   reverse(t);
     10   printf("%s\n", t);
     11   reverse(copy("XY", t));
     12   printf("%s\n", t);
     13   reverse(copy("Even", t));
     14   printf("%s\n", t);
     15   reverse(copy("Odd", t));
     16   printf("%s\n", t);
     17   reverse(copy("civic", t));
     18   printf("%s\n", t);
     19 }
     20 
     21 /* copy s1 to s2; assume s2 big enough */
     22 char *copy(s1, s2)
     23 char s1[], s2[];
     24 {
     25     int i;
     26     for(i=0;(s2[i] = s1[i]);i++);
     27     return s2;
     28 }