I am making an application for playing Dungeons & Dragons, just for fun, and I ran into a problem. I've written multiple printfs and somehow it stopped working. When it finishes the first calculation and when it has to move on to the next, then it stops. I have no idea why.
This is the code:
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
#include <string>
int main(){
    //variables
    int dmgDice;
    char entityName, dmgType;
    int initiative, dmgBonus, damage, userAC, userHp;
    //user input
    printf("Type in your armor class: \n");
    scanf("%d", &userAC);
    printf("Type in your hit points : \n");
    scanf("%d", &userHp);
    printf("type in your initative: \n");
    scanf("%d", &initiative);
    printf("type in you damage bonus: \n");
    scanf("%d", &dmgBonus);
    printf("type in you damage type: \n");
    scanf("%s", &dmgType);
    printf("your damage dice: \n");
    scanf("%d", &dmgDice);
    printf("Entity you want to damage: \n");
    scanf("%s", &entityName);
    //d20 roll
    srand((unsigned)time(0));
    printf("d20 roll: \n");
    int d20roll = (rand() % 20);
    int SUM = d20roll + initiative;
    printf("you have rolled SUM %d + %d = %d", d20roll, initiative, SUM);
    if(d20roll > 14){
        printf("\nYou've passed the enemies AC, now roll for damage!");
        printf("\nYou did %d damage to the %s!", damage, entityName);
    }
    else{
        printf("\nYou have missed, now %s attacks..", entityName);
        int entityd20roll = (rand() % 20) + 1;
        printf("\n%s passed your armor class, now it will roll for damage");
        if(entityd20roll > userAC){
            int edmg = (rand() % 12);
            int hp = userHp - edmg;
            if(hp < 0)
                hp *= -1;
            printf("\nhit points taken: \n");
            printf("%s has dealt %d damge", entityName, edmg);
        }
        else{
            printf("%s has missed you", entityName);
        }
    }
    return 0;
}
Also, how can I create a memory file so the user doesn't have to type in everything over and over again?
 
     
     
    