Jan 16, 2014 at 10:07pm UTC
hi i would to ask has some error at my code need urgent to be completed... there is error that said run time check failure 3 the variable p is being used without being initialized
need help :(
typedef struct portion{
char type[8]; float pctg;
struct portion *next;
}Portion;
typedef struct student{
char ID[9]; float cmark;
Portion *head;
}Std;
typedef struct list{
int index; Std stud[60];
}List;
void insert(List *mylist,char id[])
{
if(mylist->index == 60)
printf("Memory is full\n");
else
mylist->index++;
strcpy(mylist->stud[mylist->index].ID,id);
mylist->stud[mylist->index].head = NULL;
mylist->stud[mylist->index].cmark = 0;
}
void linkedlist(List *mylist,char id)
{
int i, choice1;
float quiz,assignment,mid,lab,home;
float total1,total2,total3,total4,total5;
char Quiz,selection;
//Quiz = 1;
Portion *p;
gets(&id);
for (i = 0; i < 60;i++)
if(strcmp (&id,mylist->stud[i].ID)==0)
p = mylist->stud[i].head;
do{
printf("Assessment Menu\n");
printf("1. Quiz\n");
printf("2. Assignment\n");
printf("3. Mid Term Test\n");
printf("4. Lab Exercise\n");
printf("5. Take Home Exercise\n");
printf("Choice: ");
scanf("%d", &choice1);
switch (choice1)
{
while(p->next != NULL){
case 1:
{
if(strcmp(p->type,"quiz")==0)
printf("\nEnter Quiz Mark(75) : ");
scanf("%f",&quiz);
total1=((quiz/75)*10);
p->pctg = total1;
p = p->next;
printf("\nPercentage of Quiz is %.1f%%",total1);
break;
}
}
case 2:
{
printf("\nEnter Assignment(10) : ");
scanf("%f",&assignment);
total2=((assignment/10)*10);
printf("\nPercentage of Assignment is %.1f%%",total2);
break;
}
case 3:
{
printf("\nEnter Mid Term Test(50) : ");
scanf("%f",&mid);
total3=((mid/50)*15);
printf("\nPercentage of Mid Term Test is %.1f%%",total3);
break;
}
case 4:
{
printf("\nEnter Lab Exercise(10) : ");
scanf("%f",&lab);
total4=((lab/10)*10);
printf("\nPercentage of Lab Exercise is %.1f%%",total4);
break;
}
case 5:
{
printf("\nEnter Take Home Exercise(5) : ");
scanf("%f",&home);
total5=((home/5)*5);
printf("\nPercentage of Take Home Exercise is %.2f",total5);
break;
}
default:
printf("Wrong Input !!!\n");
}
fflush(stdin);
printf("\nEnter A to choose another assessment: ");
scanf("%c", &selection);
}while(selection == 'A' || selection == 'a' );
}
/*void linkedlist(List *mylist, char id[])
{
Std *p;
Portion *t = (p->head) ;
if((p->head) = NULL)
(p->head) = ;
}*/
/*void display (List *mylist,portion id[])
{
while(mylist->index != NULL)
strcpy(mylist->stud[mylist->index].ID,id);
if(mylist->stud[mylist->index].ID == id)
printf("Name: %s",gets(mylist->stud[mylist->index].ID));
mylist->index++;
}*/
Jan 17, 2014 at 12:07am UTC
Last edited on Jan 17, 2014 at 12:08am UTC