/* * Gets a user integer greater than a specified value * @param int val * - The value that the user input is to be greater than */ int get_user_greater_int(int val) { int input, noc; printf("Enter an Interger Greater than %d: ", val); noc = scanf("%d", &input); clear_keyboard_buffer(); while (noc != 1 || !(input >= 0)) { printf("Invalid input\nEnter an Interger Greater than %d", val); noc = scanf("%d", &input); clear_keyboard_buffer(); } return input; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter