How to scanf only integer and repeat reading if the user enters non-numeric characters?
Use scanf(“%d”,&rows) instead of scanf(“%s”,input) This allow you to get direcly the integer value from stdin without need to convert to int. If the user enter a string containing a non numeric characters then you have to clean your stdin before the next scanf(“%d”,&rows). your code could look like this: #include <stdio.h> #include <stdlib.h> int … Read more