I need to check if the user is ,for example, typing a letter insted of a number or that he is typing too many pieces ,for example
if i asked him to Enter an array of size 3 and he by mistake puts 4.
how do I check this?
this is part of the main function only:
Code:
void main() {
int width[max_pieces], // the array of the pieces' heights
height[max_pieces], // the array of the pieces' widths
i, // index
numH,numW,numP,//heights widths and number of pieces.
puzzle[361];//the array of the puzzle.
printf("Enter puzzle height( < 20 ) width( < 20 ) number of pieces( <= 10 )\n");
scanf("%d%d%d",&numH,&numW,&numP);
while(numH>=20||numW>=20||numP>=10){
printf("Incorrect input ,try again\n");
printf("\nEnter puzzle height( < 20 ) width( < 20 ) number of pieces( <= 10 )\n");
scanf("%d%d%d",&numH,&numW,&numP);
}//while
printf("Enter array of size %d of piece heights:\n",numP);
for (i=0; i<numP; i++)
scanf("%d",&height[i]);
printf("Enter array of size %d of piece widths:\n",numP);
for (i=0; i<numP; i++)
scanf("%d",&width[i]);