endless loop for scanf - plz help
im trying to write a function that gets a number (int) from the user using scanf but for some reason the following code results in an endless loop. The point of the loop is to make sure the user enters a number and not a string:
Code:
//Function makes sure the user entered a valid entry
//and returns it
int Get_Line_Ammount()
{
int amm_of_lines;
int return_value;
printf("How many lines do you want to store?: ");
return_value = scanf("\n%d", &amm_of_lines);
while (return_value == 0)
{
printf ("\nYou did not enter a valid number, Please re-enter: ");
return_value = scanf("%d", &amm_of_lines);
}
return amm_of_lines;
}
pleazzzz, and thank you.