Computer Programming Contest Preparation

ToolBox - Source for: 7/739/a-input.c



/home/toolbox/public_html/solutions/7/739/a-input.c
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <sys/types.h>
    4 #include <sys/stat.h>
    5 #include <fcntl.h>
    6 #include <stdint.h>
    7 #include <math.h>
    8 #include <stdlib.h>
    9 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 #define MAX_LINE 257
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2012-08-26
   21  * Purpose: fun
   22  * Problem: 739 - Soundex Indexing
   23  */
   24 
   25 /*
   26  * This template reads lines of data at a time until end of file.
   27  */
   28 
   29 char line[MAX_LINE];
   30 
   31 void init()
   32 {
   33     /* FUNCTION init */
   34 } /* FUNCTION init */
   35 
   36 void dump()
   37 {
   38     /* FUNCTION dump */
   39 } /* FUNCTION dump */
   40 
   41 int getInput()
   42 {
   43     /* FUNCTION getInput */
   44     int dataReadFlag;
   45 
   46     fgets(line, MAX_LINE, stdin);
   47     if (feof(stdin))
   48         dataReadFlag = FALSE;
   49     else
   50         {
   51             /* something to read */
   52             dataReadFlag = TRUE;
   53             line[strlen(line)-1] = 0;
   54         } /* something to read */
   55     return (dataReadFlag);
   56 } /* FUNCTION getInput */
   57 
   58 void process()
   59 {
   60     /* FUNCTION process */
   61     DEBUG printf("[%s]\n", line);
   62 } /* FUNCTION process */
   63 
   64 int main()
   65 {
   66     /* main */
   67     int moreToDo;
   68 
   69     init();
   70     moreToDo = getInput();
   71     while (moreToDo)
   72         {
   73             /* while */
   74             process();
   75             moreToDo = getInput();
   76         } /* while */
   77 
   78     return EXIT_SUCCESS;
   79 } /* main */
   80