Can Some-one check if i have made any mistakes!!
Code:
#include <stdio.h>
struct comp_detail
{
char name[20][30];
int faults[20],number;
float etime[20];
float otime[20];
};
int main ()
{
int opselect;
printf("\n***************************************");
printf("\n* Please enter a selection: *");
printf("\n* Press 1 to enter data *");
printf("\n* Press 2 to print out data *");
printf("\n* Press 3 to calculate data *");
printf("\n* Press 4 to sort data *");
printf("\n* Press 5 to save data *");
printf("\n* Press 6 to quit program *");
printf("\n***************************************\n");
scanf("%d", &opselect);
switch (opselect)
{
case 1:
read_data();
break;
case 2:
print_data();
break;
case 3:
find_data();
break;
case 4:
sort_data();
break;
case 5:
save_data();
break;
case 6:
break;
}
struct comp_detail comp;
struct comp_detail read_data();
int number;
do{
printf("\nHow many competitors are there? [up to 20]");
scanf("%d", &number);
}
while ((number < 0 ) || (number > 20));
int i = 0;
do{
printf ("\nCompetitor #");
comp = read_data();
i++;
}
while ( i < number );
return(0);
}
void read_data (struct comp_detail * pt_comp_detail)
{
struct comp_detail new;
printf("\nEnter Competitors Name: "); /*prompts user to input name */
gets(name); /*calls name */
printf("\nEnter Elapsed Time: "); /*prompts user to enter elapsed time */
scanf("%.2f", &new.etime); /*scans into time, to two decimal places */
printf("\nEnter The number of faults: "); /*prompts user to enter in number of faults */
scanf("%d", &new.faults); /*scans contents into faults */
return(new);
}
void print_data (comp_detail * pt_comp_detail)
{
printf ("\nThe Competitor Named: ");
printf ("\nElement1: %d",pt_matrix->tl);
printf ("\nName Elapsed Time Faults");
printf ("\n--------------------------------------------");
for (i = 0; i < j; i++)
{
printf ("\n");
printf ("%8.2f &d",pt_comp_detail->etime[i],pt_comp_detail->faults[i]);
return;
}
}
float find_data(int faults[], float etime[])
for (i=0; i<= 19; i++)
{
int otime[i] = (4 * faults[i]) + etime[i];
return (otime[])
}
sort_data(float otime[])
{
for (i=0; i<= 19; i++)
{
int ipos[20];
float stime =9999999999999999999;
if (comp_detail.otime[i] < stime)
posi[i] = i;
}
for (i=0; i<= 19; i++)
{
printf("&c",&comp_detail.name[ipos]);
printf("\n%.2f",&comp_detail.otime[ipos]);
}
int save_data(int i, int comp_detail[])
{
FILE * newfile;
newfile = fopen("Competition.txt", "w");
for(i = 1; i <= 12; ++i)
{
fprintf(newfile,"\n%d %d", &i, &comp_detail.name[i], &comp_detail.otime[i], &comp_detail.faults[i], &comp_detail.etime[i]);
}
fclose(newfile);
return (0);
}
Please remember http://cboard.cprogramming.com/misc....bbcode#buttons next time - Salem