I cant understand the error this in code. No outputs in this code. What is the error.
checked the .dat file and it contains data.
code:
#include <stdio.h>
int main()
{
FILE *patPtrR;
char name[50];
int pCount,i,c[8];
float total,avg;
patPtrR = fopen("count.dat","r");
if (patPtrR == NULL)
{
printf("\nError..\n");
return -1;
}
fscanf(patPtrR, "%s %d %d %d %d %d %d %d %d", name,c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]);
printf("%s",name);
while (!feof(patPtrR))
{
for(i=0;i<8;i++)
{
total += c[i];
}
avg = total /8.0;
printf("Name: %s\n",name);
if (avg < 20)
printf("Severe dengue\n");
else if (avg > 20 && avg < 50)
printf("Moderate denge\n");
else if (avg > 50 && avg < 100)
printf("Mild dengue\n");
fscanf(patPtrR,"%s %d %d %d %d %d %d %d %d",name,c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]);
}
fclose(patPtrR);
return 0;
}
whats wrong with this code. i cant get any output.
No output for part B.
Need to out puts the result along with the name.
No output for part b