There is the validating function for my size which i can't manage to code it properly
void getsize(int* size, int cap){
while(1){
printf("Enter the size(whole number) of array from interval (0, %d]: \n", cap);
if (scanf("%d", size) == 1){
if ((*size > 1) && (*size <= cap)){
printf("Size: %d entered\n", *size);
break;
} else {
printf("Invalid size. Try again.\n");
}
} else {
printf("Invalid size. Try again.\n");
break;
}
}
}
What I expect from user is to enter positive whole number. Can anybody fix this or show better solution for this? Thanks.