Your 1st half of the array array[x][0] is never initialized to zero so the values start out with garbage.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
When you set a pointer and don't always use every "point" in it(especially while dealing with user input), you need memset() to set a default value.
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116