Name: Anonymous 2010-11-01 5:47
I'm reading K&R; doing the opposite of exercise 1-16. This really shouldn't take that much code, should it?
Feel free to correct the shit out of me.
P.S.
// Write a program to print all input lines that are shorter than 80 characters.
#include <stdio.h>
#define LINEMAX 80
int main()
{
int c, i = 0, j, thisstr[LINEMAX];
while ((c = getchar()) != EOF) {
// end of a line?
if (c == '\n') {
// if line short enough, print the line
if (i < LINEMAX) {
for (j = 0; j < i; j++)
putchar(thisstr[j]);
putchar('\n');
}
// and clear the variables for the next one
for (i = 0; i < LINEMAX; i++)
thisstr[i] = 0;
i = 0;
} else if (i < LINEMAX) {
// store character in array
thisstr[i] = c;
i++;
}
}
return 0;
}Feel free to correct the shit out of me.
P.S.
((c = getchar()) != EOF) is PIG DISGUSTING