I've been struggling with this bug for almost 2 days, but so far no success. If anyone could point out what is wrong with my code, I would appreciate it very much.
Using my own random numbers (100, 155, 145, 53, 88, 77, 65, 1, 15), I run my selection sort program to get the output (1, 15, 53, 65, 77, 88, 88, 145, 100). It is working up to a point where no swapping is required: 88 happens to be located at the 'no-swapping-required' position. Once it is reached, it looks like my code copies it into the next position, and does not sort the rest of the array (unsorted portion) any more. I cannot see why it is myself.
The selection sort portion of my program is shown below.
The output of this coding is (sorry for messy lines);
I also did the GDB analysis on this portion, it didn't give me any useful information. May be this is because I'm not used to using it. At this point, I'm totally at sea. I don't know what to do next. Could anyone throw me a light?