/* * C2 * Uppgift 8 * Copyright Anno Bestiae 2005 * Markus Törnqvist * Informationsteknik 2 * * vim: set tabstop=2 expandtab shiftwidth=2 * */ #define MAX_LEN 82 #include #include #include #include /* First a comparer */ /* Note the double pointers! Argh! */ int pplcmp (const char **s1, const char **s2) { return strcmp(*s1, *s2); } /* Summon the meteors */ int main() { int i; int count; char in_buf[80]; char name[80]; printf("How many people do you want, 1-200\n"); count = 0; do { fgets(in_buf, 4, stdin); count = atoi(in_buf); } while (!count); /* Just look at this: * warning: ISO C90 forbids variable-size array `table' * warning: ISO C89 forbids mixed declarations and code * AND IT WORKS IN C99! WELCOME TO THE TWENTY-FIRST CENTURY! */ char *table[count]; /* And this is thus superfluous * *table = calloc(count, sizeof(table)); */ printf("\nYou wanted %d\n", count); /* Let the jofa crack */ for (i=0; i