title: problem using fprintf
body: <p>I'm trying to print to a text file numerous variables yet it doesn't work.
  I checked and verified that i write it in the correct syntax.
  I also checked the return value and it's positive therefore i know it did write to the file, however when i open the file it's empty.</p>
  
  <p>I would be happy for some help.
  This is the code:</p>
  
  <p>I initiate DynsaleDayPtr in the main:  </p>
  
  <pre><code>FILE* DynsaleDayPtr = CreateTextFiles("sale_day.txt");  
  </code></pre>
  
  <p>Create function:  </p>
  
  <pre><code>FILE* CreateTextFiles (char* fileName)  
  {  
      FILE* saleFilePtr=NULL;  
  
      if((saleFilePtr=fopen(fileName,"a+"))==NULL)  
          printf("File couldn't be opened\n");  
      return saleFilePtr;  
  }  
  </code></pre>
  
  <p>The call to the function TextAddSale is done from a function that is called in the main:<br>
  <code>TextAddSale(DynSaleDayPtr,dynNumOfRecords);</code> </p>
  
  <pre><code>Bool TextAddSale (FILE* DynsaleDayPtr, int* dynNumOfRecords)  
  {  
  
      char id[6];  
      char name [50];  
      char priceChar[20];  
      char* tmp = NULL;  
      int price=-1;  
      DynamicRecord * newRec=NULL;  
  
      scanf("%s%s%s",id,name,priceChar);
  
      newRec = (DynamicRecord *)malloc(sizeof(DynamicRecord));  
      if (newRec == NULL)  
          return False;  
      tmp = (char*)malloc(strlen(name)+1);  
      if (tmp == NULL)  
      {  
          free (newRec);  
          return False;  
      }  
      strcpy(tmp,name);  
      newRec-&gt;productName = tmp;  
      strcpy(newRec-&gt;productId, id);  
      newRec-&gt;productPrice=atoi (priceChar);  
  
      if (fprintf(DynsaleDayPtr,"%d %s %s %d", strlen(newRec-&gt;productName),  
      newRec-&gt;productId, newRec-&gt;productName, newRec-&gt;productPrice)&gt;0)  
      {  
          *dynNumOfRecords=(*dynNumOfRecords)+1;  
          return True;  
      }  
  }
  </code></pre>
  
  <p>thanks!</p>