i'm trying to make a slot machine type thing and i wanted to assign the randomly generated numbers to certain symbols like 1 = cherry, 2 = bell and so on so i could print out the results in symbol form at the end.
i tried putting the symbols as strings in an array and assigning the numbers to the elements in the array in each slot functions but it didn't work out... is there a way to do this?
here's the code i've written so far, minus the array attempts. any suggestions would be helpful! :D
EDIT: here's an example of what i've tried doing on one of the slots but it keeps saying i need a cast to assign the integer from a pointer (i've tried searching online but idk how to do this)
char * slotOne(int randOne, const char *symbols[])
{
randOne = rand() % 4 + 1;
if (randOne = 1)
{
randOne = *symbols;
}
if (randOne = 2)
{
randOne = *(symbols+1);
}
if (randOne = 3)
{
randOne = *(symbols+2);
}
else
{
randOne = *(symbols+3);
}
return randOne;
}
this is the part of my main function where i've tried declaring the string array:
int main()
{
int x, one, two, three;
const char *symbols[4] = {"bell", "orange", "cherry", "horseshoe"};
srand(time(NULL));
one = slotOne(x);
two = slotTwo(x);
three = slotThree(x);
printf("%s - %s - %s\n", one, two, three);
//...
}
not sure if %s or %c is the right type too...