title: c reading separate words from text file using fscanf()
body: <p>I am writing a quiz program. The program should read question, answers and correct answer from csv file.
  Then it should store them in array. </p>
  
  <pre><code> void read(char question[][50], char answer1[10][10], char answer2[10][10], char answer3[10][10], char answer4[10][10], int correctAnswer[10], int *size, char fileName[], int noOfQuestion){
  FILE *reader;
  int count;
  char qBuffer[50];
  char ansBuffer1[50];
  char ansBuffer2[50];
  char ansBuffer3[50];
  char ansBuffer4[50];
  int iBuffer = 0;
  *size = 0;
  
  
  //open file
  reader = fopen(fileName, "r");
  
  //checking file is open or not
  if (reader == NULL)
  {
      printf("Unable to open file %s", fileName);
  }
  else
  {
      fscanf(reader, "%100[^\t*\?,],%[^,],%[^,],%[^,],%[^,],%d", size);
      for (count = 0; feof(reader) == 0 &amp;&amp; count&lt;*size &amp;&amp; count&lt;noOfQuestion; count++){
      //Reading file
          fscanf(reader, "%100[^\t*\?,],%[^,],%[^,],%[^,],%[^,],%d", qBuffer, ansBuffer1, ansBuffer2, ansBuffer3, ansBuffer4, iBuffer);
  
          //Storing data
          strcpy(question[count], qBuffer);
          strcpy(answer1[count], ansBuffer1);
          strcpy(answer2[count], ansBuffer2);
          strcpy(answer3[count], ansBuffer3);
          strcpy(answer4[count], ansBuffer4);
          correctAnswer[count] = iBuffer;
  
          // Check Correct Number of Items Read
          if( count == noOfQuestion )
          {
              printf("There are more items in the file than MaxNoItems specifies can be stored in the output arrays.\n\n");
              *size = count;
          }
          else if( count != *size - 1 )
          {
              printf("File is corrupted. Not as many items in the file as specified at the top.\n\n");
              *size = count;
          }
          //Break if reached end of file.
          if (feof(reader))
          { break;}
          }
          fclose(reader);
  }
  }
  </code></pre>
  
  <p>This the csv file to read from. each question and answers are in one line.</p>
  
  <pre><code>What function do you use to open a file?,fscanf,fclose,fopen,main,3
  Which of the following is not a variable type?,int,float,char,string,4
  How many bytes is a character?,8,4,2,1,4
  What programming language have you been studying this term?,B,A,D,C,4
  Which of the following is a comment?,#comment,//comment,$comment,%comment,2
  Which of these is in the C Standard Library?,stdio.h,studio.h,iostream,diskio.h,1
  What tool do we use to compile?,compiler,builder,linker,wrench,1
  What function do you use to close a file?,fscanf,fclose,fopen,main,2
  How do you include a file?,#include,//include,$include,%include,1
  What are you doing this quiz on?,paper,whiteboard,computer,chalkboard,3
  </code></pre>