Gets a user integer greater than a specified value

PHOTO EMBED

Fri Nov 15 2024 17:37:17 GMT+0000 (Coordinated Universal Time)

Saved by @Bantling21

/*
* 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;
}
content_copyCOPY