nakaly
New Coder
Hello World!
I keep getting crashed my IDE when I enter a letter in the scanf instead of a number. I tried to use scanf's return value to check that it succesfully matches the input but it still crashes when I enter a letter.
Thank you in advance for any help.
I keep getting crashed my IDE when I enter a letter in the scanf instead of a number. I tried to use scanf's return value to check that it succesfully matches the input but it still crashes when I enter a letter.
Thank you in advance for any help.
C:
int getMove(Board_t *self, unsigned int *x, unsigned int *y) {
//Reads values from keyboard and returns them in x and y.
int inputsMatched = 0;
if (!errorsInBoard(self)) {
do {
printf("Select a cell [row].[column]: ");
fflush(0);
inputsMatched = scanf("%u.%u", x, y);
}
while (inputsMatched != 2 || *x >= self->dim1 || *y >= self->dim2);
return 0;
}
else {
return -1;
}
}