Datei: p3-10.c
1 /* 2 * p3-10.c 3 * Beispielprogramm 10, Abschnitt 3 4 * Eingabezeilen, -worte und -zeichen zaehlen 5 */ 6 7 #include <stdio.h> 8 9 #define YES 1 10 #define NO 0 11 12 void main(void) 13 { 14 int c, nl, nw, nc, inword; 15 16 inword = NO; 17 nl = nw = nc = 0; 18 19 while ((c = getchar()) != EOF) { 20 ++nc; 21 if (c == '\n') 22 ++nl; 23 if (c == ' ' || c == '\n' || c == '\t') 24 inword = NO; 25 else if (inword == NO) { 26 inword = YES; 27 ++nw; 28 } 29 } 30 31 printf("%d %d %d\n", nl, nw, nc); 32 33 } /* main() */
Erzeugt von c2html 1.01 |