Good question. Always try to understand everyting you use :)
I wrote it for a simple game. The problem with cin is that when you use it to store input directly into a integer variable, the program will crash when the user inputs a character. Thats wy in 'real' programs you'll never see cin>>integer.
Solution? Store the input in a variable of type char[], and then store that value into a variable of type string.
As you may know, a character has an integer value of type 0, so if the user would type a character, the inputvalue would become 0. Thats wy i used
input==0 && temp[0]!=0
in the condition for the while loop: in this case the loop should go on asking the user for input.
I guess you understand the purpose of max and min.
The reason i used this function in this program is because getint() also uses getline(). Using different things often causes problems, especially when its about interaction. So when i saw your code i rememberd my old getint() function :P
I didnt come up with that function all by myself, aldo i have changed some things. I got it orginially from this site:
http://www.augustcouncil.com/~tgibson/tutorial/iotips.html. Really usefull stuff, i recommend you to read it.