I can't seem to "return" a value that is stored in "diff". I am suppose to give the value of diff to "int main()" to activate the void low() or void high() functions. But the program I did skips
difficulty(diff);
if (diff == 'l')
{low();}
else if (diff == 'h')
{high();}
This is my codes (I removed the function random() because it is not gonna be "bumped" and my problem is mainly on how to transfer the value from a function to activate other functions.
int difficulty(char diff)
{
char difficulty;
printf("Level of difficulty? (l-Low,h-High) - ");
scanf("%c",&difficulty);
while(difficulty != 'l' && difficulty != 'h')
{
scanf("%c",&difficulty);
}
if (difficulty == 'l')
{printf("WEAK! :3\n");
diff = 'l';}
if (difficulty == 'h')
{printf("PRO! XD\n");
diff = 'h';}
return diff;
}
void low()
{
printf("low");
}
void high()
{
printf("high");
}
int main()
{
char diff;
difficulty(diff);
if (diff == 'l')
{low();}
else if (diff == 'h')
{high();}
random();
system("pause");
}
Any help will be appreciated.