Code:
for (x = 0; x<count; x++)
{ printf("Enter the final average for the student: ");
scanf_s("%f", i);
element->ave = i;
element = element->next;
}
Ok there is a definite problem here as it produces an error saying cannot write to location 0x0000000.
Also count is not incrementing as I think it should, I will link my new while loop, mostly borrowed from tab.
Code:
while(!feof(pread))
{
fgets(tempname, 128, pread);
for(x = 0; x<128;x++)
{
if(tempname[x] == '\n')
{
tempname[x] = '\0';
break;
}
}
count++;
strcpy(element->name, tempname);
element->ave = i;
element->next = head;
head = element;
}
I added the for loop to add a null terminator to the string, i think that would work. count shows up as only 1. Should be 3 from my input file which has 3 names separated by '\n'.
Im assuming this is a pointer error in my linked list because i get the output "Enter student average" but when I input the double number the error occurs and the program stops working. Any suggestions?