I think that the problem is in lines 59-63
#include <stdio.h>
#include "genlib.h"
#include "ctype.h"
#include "simpio.h"
#include "string.h"
typedef struct{
char name[30];
long sell;
double supply;
}domiT;
void ypologismoi(domiT stx[],int *p,FILE *infile);
void emfaniseis (domiT stx[],int *p,FILE *outfile);
main()
{
int p;
FILE *infile,*outfile;
domiT stx[100];
ypologismoi(stx,&p,infile);
emfaniseis(stx,&p,outfile);
system("pause");
}
void ypologismoi(domiT stx[],int *p,FILE *infile)
{
char file[15];
int sarwseis;
char comments[68];
char name[30];
char termch;
long sell;
while(TRUE)
{
printf("Enter file's name: ");
gets(file);
infile=fopen(file,"r");
if(infile!=NULL) break;
printf("Cannot open file %s !! Try againn",name);
}
*p=0;
while(TRUE)
{
sarwseis=fscanf(infile," %30[^,], %ld,%68[^,],%c",name,&sell,comments,&termch);
if(sarwseis==EOF) break;
if(sarwseis!=4 || termch!='n')
printf("ERROR try to find the error plz! " );
strcpy(stx[*p].name,name);
stx[*p].sell=sell;
if(sell>=300000)
stx[*p].supply=sell*5/100.0;
else
stx[*p].supply=sell*3/100.0;
(*p)++;
}
}
void emfaniseis (domiT stx[],int *p,FILE *outfile)
{
double sum;
char newname[15];
int i;
sum=0;
for(i=0;i<*p;i++)
sum+=stx[i].supply;
printf("Enter the NEW file's name: ");
gets(newname);
outfile=fopen(newname,"w");
fprintf(outfile," %-30s %10s n","ONOMATEPONYMO","PROMHTHEIA");
for(i=0;i<40;i++)
fprintf(outfile,"%c","-");
fprintf(outfile,"n");
for(i=0;i<*p;i++)
fprintf(outfile,"%-30s %10g n",stx[i].name,stx[i].supply);
for(i=0;i<40;i++)
fprintf(outfile,"%c","-");
fprintf(outfile,"n");
fprintf(outfile,"%-30s %10g","SYNOLO PROMHTHEIWN:",sum);
}