/* voteReaderWithoutErrorChecking.cpp   Demonstrate reading data from a file
   P. Conrad, 9/23/04, CISC105, Fall 2004 */

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  FILE *infile;
  char state[3];  /* 2 for the state, one to terminate the string */
  char candidate;
  int electoralVotes;

  int result; /* for result of scanf */

  infile = fopen("electorelVotes.dat","r");

  /* no check to see if infile is not NULL... this is bad style! */

  result = fscanf(infile,"%s\t%c\t%d",&state, &candidate, &electoralVotes);
  while (result != EOF)
    {
      printf("State=%s Candidate=%c Votes=%d\n",
	      state, candidate, electoralVotes) ;
      result = fscanf(infile,"%s\t%c\t%d",&state, &candidate, &electoralVotes);
    }
  
  return 0;
}

