Hi everyone,
im new here and ive got this code. No error message but i cant get my ressult after compile and run. System pause etc just show the message Syntax: programfile inputfile at the end.
What i need to do so i can wright in the console year and average exam notes?
thx for any help and sry for my english
[tag]
Code:
#include <stdio.h> #include <conio.h>
struct foitrec {
char fname[15];
char lname[20];
int year;
char exam;
int snote;
};
void main(int argc, char *argv[]) {
FILE *fptr;
struct foitrec ftt;
float aver;
int count;
if(argc==2) {
if(fptr=fopen(argv[1],"r")) {
aver=0.0;
count=0;
while(fscanf(fptr,"%s %s %d %c %d",ftt.fname,ftt.lname,&ftt.year,&ftt.exam,&ftt.snote)!=EOF)
if(ftt.exam=='A' && ftt.year==1995) {
aver+=ftt.snote;
++count;
}
aver/=count;
printf("Average=%f\n",aver);
} else
printf("Can't open file %s\n",argv[1]);
} else
printf("Syntax: programfile inputfile\n");
}
[/tag]