gcc -g uniqRand.c
ddd a.out &You'll notice that the window is separated intro 3 sections.
Alteratively, left click the place where you want to set the break
point, and push the ``Break'' button of the bar below menu bar.
The green arrow moves to the next line, indicating that the statement max = MAX; was executed.
Hah, it never goes inside of the if statement. The first random number should be always new, so it should be added.
We forgot ``!'' in front of MemberQ(): we want to add the value r if r is NOT already a member.
if (! MemberQ(resultPtr, cntr, r)) {
Then go to the terminal and recompile.
Alternatively, you can just open the source code with emacs from the terminal, and rund the ddd and emacs in parallel. In this case, you can select ``Source -> Reload Source''. Or if you recompile and ``run'' again, it will automatically load the edited source.
You'll notice a new box in ``Display'' window. The first number starting with ``0x'' is value of the pointer (address in hexadecimal number), then you get the contents of the array elements.
The first selectable box indicate what kind of data (decimal for integer, unsigned for unsigned integer and float for floating points).
The 2nd box indicate the size of each element. If you look at the table which lists the range of variables, the column ``bytes required'' contains the value required for each type of variable. Integer variable uses 4 bytes in x86/linux, so we are selection ``words(4)''.
Alternatively, after left-clicking the location, press and hold down ``Break'' button in the bar below menu bar. You can see this option.
Right click the red ``Stop'' sign, and select ``Properties''. Or double click the ``Stop'' sign. Then put a C logical expression in the ``Condition'' box.
For the stop sign left of UniqRandInt(), you can put i > 2. When you run the program, the stop sign will be ignored until i become greater than 2.
You can select a variable (or an array elements) by left-click, and push the button ``Set'': located at the right end of the bar below menu bar. In the pop up window, you can type in the value.
Or use the ``Debugger Console'' and type in a set command
set variable arr[i] = 4
In this example, the current value of i will be used.