input validation

Hey guys,
Im learning C online, and its hard somtimes to understand the concepts, w/o being in class asking questions. I was wondering hat would be the easiest and fstest way to understand numeric validating(no characters) and could anyone break it in easy steps? im new, but really excited about C and will learn fast. I found this program in one of the books, but it doesnt really explain whats going on under the hood, if there is an easier way of doing it please let me know.
I dont understand things, that happens in the loop.,
Cheers, and thanx a lot for your time!!! )

#include<stdio.h> // include header
int get_int(void); // Function prototype is to be declared as the function is defined after main()
main() // Change to int main()
{
printf ("Enter an integer:");
get_int(); // Call function. No error as the function was declared previously
printf ("Good!\n");
}
int get_int(void)
{
int input;
char ch;
while (scanf("%d", &input) != 1) // scanf returns the no of items successfully read. If user inputs a character then it won't be read into 'input' and scanf returns 0.
{
while ((ch = getchar()) != '\n') // Get all the characters given by the user (that is till '\n' was entered) then use putchar() to print it on the screen
putchar(ch); // dispose of bad input
printf(" is not an integer.\nPlease enter an ");
printf("integer value, such as 25, -178, or 3: "); // go back to the while loop where scanf will take the input from the user again
}
return input;
}

Ok, it's a simple but not a strong validation. For example, in most of C implementations scanf can't detect integer overflow (it's possible to type a huge number and to get some wrong number with scanf(...) == 1).
More strong (but not ideal) method is (an example only):

>More strong (but not ideal) method is (an example only)
Only an example because by the time you test for overflow, the damage is already done. Keep in mind that once you invoke undefined behavior, the rest of the program is undefined. You need to test before the damage is done either with a library function that's smarter (such as strtol) or by doing it all manually (which I don't recommend unless you know what you're doing):

Notice that both of these solutions rely on unformatted input using fgets and then a more precise validation of the string in memory. It's much easier to validate your input without having to worry about mucking with the stream at the same time.

the program u wrote checks whether the entered input is an integer or character
if it is an inter it returns "good".
Basically you are using the
"int get_int(void)"
to call a function to perform your task.

1.the program continues ubtil u enter 1
2.if u enter any character or string your last character is always "\n" that is automatically added in the last of the string u write.
so the program continues until the end if the string
3.when while loop continues it prints the character u entered in the string since putchar is used to print the char on the output screen.

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...