training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

filterb.c (513B)


      1 /* Exercise 8.23 */
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <ctype.h>
      6 
      7 #define SIZE 10
      8 #define BUF  255
      9 
     10 int main(void)
     11 {
     12    char strings[SIZE][BUF];
     13    int i = 0;
     14 
     15    printf("Give me a string (%d to end): ", EOF);
     16    gets(strings[i]);
     17 
     18    while( atoi(strings[i++]) != EOF ) {
     19       printf("Give me a string (%d to end): ", EOF);
     20       gets(strings[i]);
     21    }
     22 
     23    for(i = 0; i < SIZE; i++) {
     24       if( tolower((int)strings[i][0]) == 'b')
     25 	 printf("%s\n", strings[i]);
     26    }
     27 
     28    return 0;
     29 } /* E0F main */
     30