I'm new to arrays and getchar, help!
While making a simple code for the popular Yahtzee game, while I don't know how to assign random values for dice, i guess user input is fine enough. lol.
I thought of reading user input like this:
Code:
int main (int argc, char **argv) {
int diceVal[5];
int n;
int next;
printf ("Please enter dice values: \n");
scanf ("%d %d %d %d %d", &diceVal[0], &diceVal[1], &diceVal[2], &diceVal[3]...etc.
return (0);
}
I just thought if there were a 1000 values, no one is going to sit there assigning values a 1000 times, also is it better to use getchar instead of scanf to recognize the values? And instead of typing a million times over the diceVal, do I put it in some kind of loop? I'm not sure how to put arrays into loops, when I tried, it always gave some bizarre answer or it failed to compile