I'm trying to create a statistic showing a percentage by dividing two other statistics, but the code I've tried doesn't seem to work. The relevant code is below. The line giving me the problem is player->hits_to_miss=((*player)).number_hits/(player->total_shots)*100:
Code:
void update_stats (Stats *player, Boolean hit_status)
{
if (hit_status == TRUE)
{
((*player).number_hits)++;
}
else
{
(player->number_misses)++;
}
(player->total_shots)++;
player->hits_to_miss=((*player)).number_hits/(player->total_shots)*100;
}
void print_stats (Stats player)
{
printf ("Hits: %d, Misses: %d, Total Shots: %d, Accuracy: %.1lf percent\n", player.number_hits, player.number_misses, player.total_shots, player.hits_to_miss);
}
I've tried various iterations such as
Code:
player->hits_to_miss=(player->number_hits/(player->total_shots)*100
Code:
player->hits_to_miss=((*player).number_hits/((*player).total_shots)*100
, but basically I'm shooting in the dark. Is there a way to do this?