sorry I didn't make my self clear last time so Im
posting the same question again with another limitation.
Im allowed to use only <stdio.h>
I think that the problem is with the %d.
maybe it will be easier with %s??
but Im not sure how to do it.
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:
#include <stdio.h>
#define max_Size 19
#define max_pieces 10
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||numH<=0||numW<=0||numP<=0){
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]);