I am trying to print a text file, but it does a lot of work. I checked and verified that I write it in the correct syntax. I also checked the return value and it is positive so I know that he has written the file, although when I open the file, then it is empty.
I would be happy with some help. This code is:
I start DynsaleDayPtr in the main:
FILE * DynsaleDayPtr = CreateTextFiles ("sale_day.txt"); Create function:
FILE * CreateTextFiles (char * fileName) {FILE * saleFilePtr = NULL; If ((saleFilePtr = fopen (filename, "a +") == faucet ()) printf ("The file could not be opened \ n"); Return salesfilter; } Function TextAddSale is called by a function called main:
TextAddSale (DynSaleDayPtr, dynNOfRecords); Bull TextAdsele (file * DynsaleDayPtr, int * dynNOfRecords) {four IDs [6]; Four names [50]; Four Price Clients [20]; Char * tmp = NULL; Int price = -1; Dynamic record * nurrock = null; Scanf ("% s% s% s", id, name, priceChar); NewRec = (Dynamic Racked *) Molec (Dynamic Records); If returned (newRec == NULL) wrong; TMP = (four *) Molkok (Stellen (name) +1); If (tmp == faucet) {free (newreak); return false; } Strakpy (tmp, name); NewRec- & gt; Product name = tmp; Strcpy (newRec-> Product ID, ID); NewRec- & gt; ProductPrice = Auto (Price Price); If (fprintf (DynsaleDayPtr, "% d% s% s% d", strlen (newRec-> product name), newRec-> product ID, newRec-> product name, newRec-> product process) & Gt; 0) {* dynNumOfRecords = (* dynNumOfRecords) + 1; The return is true; }} Thanks!
You need to flush the stream.
Phfal (FILE *); Of course, if you have done this, you have to stop the stream.
fclose (FILE *);
Comments
Post a Comment