A quick glance shows that line 43-47 will loop. Notice where the braces are. Also may help to indent your code properly to see where the loops actually are.
A couple of comments:
srand (time(NULL)); // only once. . No this line will be executed each time the function is called. Line 8 is better placed at line 24 so that it is only done once when the program starts.
I think you want to put lines 49 - 155 inside the while loop.
Hope that helps,
This was very helpful! Thank you guys very much.