From 59d1a2921ec51421486ac0766897f94a30398f65 Mon Sep 17 00:00:00 2001 From: Dave Vandervies Date: Sat, 14 Dec 2019 16:24:44 -0500 Subject: [PATCH] Populate mods before we use it While we're here, otherprofs[] doesn't need to be fully zeroed to be a valid empty string. --- character.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/character.c b/character.c index 9c95e8a..9108545 100644 --- a/character.c +++ b/character.c @@ -333,19 +333,17 @@ void genBackground(){ } size_t genChar(char* output, size_t maxlen){ + int i; profs = 0; languages = 0; - for(int i = 0; i <= 100; i++){ - otherprofs[i] = '\0'; - } - int i; - genRace(); - genClass(); - genBackground(); + otherprofs[0] = '\0'; for(i=0; i < 6; i++){ stats[i] = dieroll(3,6); mods[i] = (stats[i]/2)-5; } + genRace(); + genClass(); + genBackground(); snprintf(output, maxlen, "Race = %s\r\nBackground = %s\r\nClass = %s\r\nStr = %d %d\r\nDex = %d %d\r\nCon = %d %d\r\nInt = %d %d\r\nWis = %d %d\r\nCha = %d %d\r\n\r\nHP: %d\r\n", race, background, class, stats[STR], mods[STR], stats[DEX], mods[DEX], stats[CON], mods[CON], stats[INT], mods[INT], stats[WIS], mods[WIS], stats[CHA], mods[CHA], hp);