This is the code that I'm struggling with:
It compiles fine, but when I try to run the function, the program crashes. Can someone tell me what is wrong?Code:typedef struct { char surname[20]; char name[15]; int addLevel; int subLevel; int correct; int wrong; int correctSession; int wrongSession; } USER; //I *know* I have the definitions correct. I've passed a USER struct to the function via pointer, in case that confuses anyone. void mathAssess(USER *userPtr) { float hitRate = ((userPtr->correct)/(userPtr->correct + userPtr->wrong))*100; float hitRateSession = ((userPtr->correctSession)/(userPtr->correctSession + userPtr->wrongSession))*100; char pc = 37; //I'm trying to print out "%". This seemed the easiest way. printf("Current Statistics for user %s %s:\n\n", userPtr->name, userPtr->surname); printf("Total Correct Answers:%15d\n", userPtr->correct); printf("Total Incorrect Answers:%13d\n", userPtr->wrong); printf("Correct Answers this Session:%8d\n", userPtr->correctSession); printf("Incorrect Answers this Session:%6d\n", userPtr->wrongSession); printf("Total Hit Rate:%22.2f%c\n", hitRate, pc); printf("Hit Rate This Session:%15.2f%c\n", hitRateSession, pc); }



LinkBack URL
About LinkBacks


