#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "string.h"
#include "ctype.h"
typedef struct
{
char name[30];
int apousies;
}telikaT;
void ypologismoi(FILE *inArxeio,telikaT students,int *p100,int *pAll);
void emfaniseis(FILE *outArxeio,telikaT students,int *p100,int *pAll);
main()
{
FILE *inArxeio,*outArxeio;
telikaT students[30];
int p100,pAll;
ypologismoi(inArxeio,students,&p100,&pAll);
emfaniseis(outArxeio,students,&p100,&pAll);
system("pause");
}
void ypologismoi(FILE *inArxeio,telikaT students,int *p100,int *pAll)
{
char infilename[30];
char name[30];
int apousies;
char sxolia[68],termch;
int sarwseis;
*pAll=0;
*p100=0;
while(TRUE)
{
printf("Enter the name of the file : ");
gets(infilename);
inArxeio=fopen(infilename,"r");
if(inArxeio!=NULL)
{
break;
}
printf("Cannot open file %s ///\\\ Try again!\n",infilename);
}
while(TRUE)
{
sarwseis=fscanf(inArxeio,"%30[^,], %d, %68[^\n]%c",name,&apousies,sxolia,&termch);
if(sarwseis==EOF)
break;
if(sarwseis!=4 || termch!='\n')
printf("Error\n");
if(apousies>100)
{
strcpy(students[*p100].name,name);
students[*p100].apousies=apousies;
(*p100)++;
}
(*pAll)++;
}
fclose(inArxeio);
}
void emfaniseis(FILE *outArxeio,telikaT students,int *p100,int *pAll)
{
int i;
char outfilename[30];
printf("Type the name of the NEW file : ");
gets(outfilename);
outArxeio=fopen(outfilename,"w");
fprintf(outArxeio,"%-30s %9s","ONOMATEPWNYMO","APOYSIES");
for(i=0;i<40;i++)
fprintf(outArxeio,"%c","-");
fprintf("\n");
for(i=0;i<*p100;i++)
fprintf(outArxeio,"%-30s %9d\n",students[i].name,students[i].apousies);
for(i=0;i<40;i++)
fprintf(outArxeio,"%c","-");
fprintf("\n");
fprintf("SYNOLO MATHITWN: %d\n",*pAll);
fprintf("SYNOLO APONTWN: %d\n",*p100);
}
**I cannot figure out how can i pass a struct threw a void function.
Also can you tell me what can i do for the program to work fine??
Thanks in advance.....sorry for my terrible english **