I'm getting an error with this code. The output looks like this: enter image description here
Why is the output half normal?
I want the output to be:
2 ppa 90 90 98 89 49 83.20 B
junior 90 90 90 90 90 90.00 A
Here is my code:
void class_result(){
system("cls");
fptr=fopen("stdnin.txt","r");
if(fptr==NULL)
{
printf("ERROR!!! FILE COULD NOT BE OPEN\n\n\n Go To Entry Menu to create File");
printf("\n\n\n Program is closing ....");
getch();
exit(0);
}
printf("\n\n\t\tALL STUDENTS RESULT \n\n");
printf("====================================================\n");
printf("R.No. Name P C M E CS %age Grade\n");
printf("====================================================\n");
// while(fscanf(fptr,"%d %s %d %d %d %d %d %.2f %c",&st.rollno,st.name,&st.p_marks,&st.c_marks,&st.m_marks,&st.e_marks,&st.cs_marks,&st.per,st.grade)!=EOF){
while(fread(&st,sizeof(st),1,fptr))
{
printf("%-6d %-10s %-3d %-3d %-3d %-3d %-3d %-3.2f %-2c\n",st.rollno,st.name,st.p_marks,st.c_marks,st.m_marks,st.e_marks,st.cs_marks,st.per,st.grade);
}
// while(fread(&st,sizeof(st),1,fptr))
// printf ("%d %s \n",st.rollno, st.name);
fclose(fptr);
getch();
}