used without being initialized
it says stu_id is used without being initialized. What should I do about it?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
void print_all_courses_all_students(struct student student_list[],int *stu_count)
{
// int i;
char course_name[7];
int temp=0;
int i, stu_index;
// struct class1 *p1;
struct class1 *p1;
for (i=0; i<*stu_count; i++)
if (student_list[i].id != -1)
cout<<student_list[i].id<<"\n";//cout<< "Student "<<stu_id<< "does not exist.";
for (i=0; i< *stu_count; i++)
{
int stu_id;
if (stu_id == student_list[i].id) stu_index = i;}
class1* head = student_list[stu_index].p_class_from_student;
class1* tmp = head;
while(tmp != NULL){
class1 *A, *B;
A = head;
B = A->p_class;
while(B != NULL){
int result = strcmp (A->course_name, B->course_name);
//If value is less than 0 then perform swap function to rearrange
if (result > 0){
char tmp[7];
strcpy(tmp, A->course_name);
strcpy(A->course_name, B->course_name);
strcpy(B->course_name, tmp);
}
A = A->p_class;
B = A->p_class;
}
tmp = tmp->p_class;
}
if (student_list[i].id != -1) {
// cout<<"\nThe course(s) of student with ID %d: \n\n", student_list[i].id;
cout<<"\nThe course(s) of student with ID "<<student_list[i].id<< ": \n\n";
cout<<"Course Name Section No. No. of Credit(s) \n";
p1 = student_list[i].p_class_from_student;
while (p1 != NULL) {
cout << p1->course_name << " " << p1->section << " " << p1->credit<<"\n";
p1 = p1->p_class;
}
}
}
|
¿initialize it?
1 2
|
int stu_id;
if (stu_id == student_list[i].id)
|
¿what do you expect to happen there?
Topic archived. No new replies allowed.