Having error in reading file C programming
<p>Figure 1 shows a text file (itemlist.txt) that store item code, item name, item price, and item quantity. Write a program to read the data from the text file and then display the item’s information which with 0 quantity on the screen. </p>

<p>Assume that data stored in the file are:</p>

<pre><code>itemCode            a unique unsigned integer that differentiates an item from another
itemName            the name of an item (not more than 50 characters)
itemPrice           the current selling price of an item
itemQuantity        an integer that shows the quantity of an item               
</code></pre>

<p>Also, assume that the fields in the file are separated by a comma.  </p>

<p>File content:</p>

<pre><code> 3123,Potato Chips,3.99,8
 2213,Peanut butter,7.99,0
 4533,Candy,1.05,14
 8744,Ice cream,2.50,0
</code></pre>

<p>Example output:</p>

<pre><code> Out-of-stock items:
 -------------------------------
 2213   Peanut butter   7.99
 8744   Ice cream   2.50
</code></pre>

<p>Can anyone read my code and see what is the problem? The program abnormally exits, but I don't know why..</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
 int main()
 {
   unsigned int itemCode;
   char itemName[50];
   float itemPrice;
   int itemQuantity;

   FILE *fp;
   fp = fopen("itemlist.txt", "r");
   printf("%s","Out-of-stock items: \n");
   printf("-------------------------");

   while(!feof(fp)) {
    fscanf(fp, "%4u,%[^,],%f,%d", &amp;itemCode, itemName, &amp;itemPrice, &amp;itemQuantity);

    if(itemQuantity == 0){
        printf("%u %s %f\n",itemCode,itemName,itemPrice);
    }


   }
    fclose(fp);

    return 0;



}
</code></pre>

<p>And also I would like to know that if the name of an item is not more than 50 characters, how many elements are there in the itemName array?</p>