You only need modify sorts.C. In case you're interested, I've included all the source code, but you don't need to look at it.
Open up a new file in the editor of your choice named, for
example, seq1. Type in a short sequence suitable to input to
sorts (i.e., a sequence of numbers preceded by the length of
the sequence). For example:
5 5 4 3 2 1
Now try:
sorts < seq1
This causes sorts to get stdin from seq1.
The most common debugging tasks are displaying variables, setting breakpoints, and controlling execution. To display a variable, right-click on the variable in code and select Display. Everything that is displayed will appear in a separate pane; you can rearrange objects in that pane by clicking and dragging; right-clicking lets you modify them. For more complicated variables, you may need to select what you want to display first.
To set a breakpoint at a function, right-click on the function name and select Break at. To set a breakpoint at a line, left-click to set the line, then right-click and select Set Breakpoint.
The floating button bar lets you control your program's execution. Run runs a program from the beginning. Step steps the program, going into function calls. Next steps the program, stepping over function calls. Cont (continue) runs the program from its current point. Interrupt stops the program, useful if you've gotten into an infinite loop.
To debug sorts, you'll need to arrange for the debugger to provide an input sequence. Go to Program...Run. In the Run with arguments box, type < file, where file is an input file like seq1, above. Then hit Run to start your program. Note that this is just filling in the rest of the command line you used to invoke sorts outside of ddd.
You can also make files using randseq from
the command line.
randseq -l 50 > file
Here file is the filename of your choice, and of course you can
replace 50 with any other number.