/* * Read values and sort them using "insertion sort." */ #include #include #define MAXVALS 100 /* max # of values to sort */ int main() { void tableInsert(int [], int, int); void tablePrint(int [], int); int table[MAXVALS]; /* table of values */ int n; /* number of values in table */ int r; /* value returned by scanf */ int v; /* current value */ for (n = 0; (r = scanf("%i", &v)) != EOF; n++) { if (r != 1) { printf("Input error after reading %i values\n", n); break; } if (n == MAXVALS) { printf("Table full after reading %i values\n", n); break; } tableInsert(table, n, v); } tablePrint(table, n); return EXIT_SUCCESS; }