I am making a Hangman game and I have encountered an issue. In this code the program selects a random word from a finite number of values, then it takes the random word and masks it so that in future coding it will allow the user to guess the letters.
The issue lies in the masking, I have no idea how to link it to future code for the loop and counter as well as output the masked word, as can be shown with;
mask[i] = '_';
printf("%s", mask[i]);
I get the error, Param_(2) in call to 'printf' must be the address of a string. Actual type 'int' which when I run I get a weird error where I have to halt debugger.
Any solutions?
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <time.h>
#include <string>
#define ARRAY_SIZE 10
int main()
{
//randomwordgenerator
char word[ARRAY_SIZE][200] = { "tiger", "lion", "elephant", "zebra", "horse", "camel", "deer", "crocodile", "rabbit", "cat" };
int x = 0;
srand(time(0));
x = rand() % ARRAY_SIZE;
system("pause");//will pause the rand function
//masking and unmasking word
char m = strlen(word[x]);//will count the number of letters of the random word
int mask[200]{};
for (int i = 0; i < m; ++i) //loop until all leters are masked
{
mask[i] = '_';
printf("%s", mask[i]);
}
return 0;
}