Commit 4e7a8178 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

2.09: test return value of scanf

parent 0052e05c
......@@ -44,7 +44,10 @@ int main (void) {
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
printf("Please enter a number for row %d, col %d: ", i+1, j+1);
scanf("%d", &quadrat[i][j]);
if (scanf("%d", &quadrat[i][j]) != 1) {
printf("Illegal character entered, exiting.\n");
return 1;
}
}
}
printf("\n\n\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment