I'm trying to create a mini game where if a user inputs "A" it will attack and deduct damage based on user input. However "Move: " seems to print twice. How do I stop it from doing that? Also, how do I stop my program to print the last line of current health if health is equal to zero already? Thank you so much for any help.
typedef struct{
char coolName[100];
int health;
int defense;
}Hero;
int main(){
Hero hero1;
printf("Enter hero name: ");
scanf("%s", &hero1.coolName);
printf("Enter health: ");
scanf("%d", &hero1.health);
printf("Enter defense: ");
scanf("%d", &hero1.defense);
char move;
int attack;
do{
printf("Move: ");
scanf("%c%d", &move, &attack);
if(move=='A'){
hero1.health = hero1.health - (attack-hero1.defense);
printf("\n%s current health - %d\n", hero1.coolName, hero1.health);
if(hero1.health<=0){
break;
}
}else if(move=='S'){
printf("I surrender");
break;
}
}while(hero1.health>0);
printf("%s has fallen", hero1.coolName);
}```