Programming makes me look so stupid currently lol.
Code:
while(!feof(pread))
{
fgets(tempname, 128, pread);
element =(Student *)malloc(sizeof(Student));
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;
}
That looking better? I create element earlier in the main function, but im not allocating memory to it until this.
While im debugging after I execute this loop
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;
}
It shows i as an integer though ive defined it as a double and and its saying in the value of p <Bad Ptr>. So its a bad pointer im guessing? I dont understand whats happening under the hood too well, so I dont get these messages.