hello people.. I really need help...

I want to debug my program in the way to see each variable..

I have a huge while {...}

and in that while something goes wrong..

I have to generate numgers.. the excercise is called hotter, colder...

I got 2 .cpp files and 2 .h files..

one of them think of a number and says hotter, colder

and the second want to guess it but very fast...

don't try to think about the solution of this program(your mind will be blowed)

but try to help me in debugging ..

my program generates numbers, and that number is being held in one of the if()s

so I want to see where my program goes, what are the veriables' values, and to perform it each time that line changes in debug...

I use G++ and only can see it with gdb...(command)

please tell me commands, to do so , here is my code(though it is not connected with my question)

```
#include<cstdlib>
#include"grader.h"
#include<iostream>
#include<ctime>
using namespace std;
int HC(unsigned int N)
{
unsigned short int n = 0;
unsigned short int G;
unsigned short int one_past_of_G=1;
unsigned short int previous_of_past_of_G =1;
short int temper_of_previous = 0;
short int temper_of_pastpast = 0;
register int i;
int test;
G = (rand() % N)+1;
short int temper = Guess(G);
temper++;
one_past_of_G = G;
srand(time(NULL));
G = (rand() % N)+1;
while(temper != 0 || Guess(G) != 0){
n++;
temper = Guess(G);
if(n > 2){
if(temper == 1){
if(previous_of_past_of_G < one_past_of_G && one_past_of_G < G){
if(temper_of_previous == 1){
if(temper_of_pastpast == 1){
for(i = 0; test <= G+5 && test > one_past_of_G || i < 10; i++){
test = ((rand()%one_past_of_G-(one_past_of_G))+(G +1));
if(test > one_past_of_G && test < G+5){
G = test;
}
}
}else{
G = ((rand()%previous_of_past_of_G-(previous_of_past_of_G))+(G +1));
}
}
cout << "(temper == 1){\n" <<
"\tif(previous_of_past_of_G < one_past_of_G && one_past_of_G < G) \n" << G;
}
else if(previous_of_past_of_G > one_past_of_G && one_past_of_G < G){
if(temper_of_previous == -1){
if(temper_of_pastpast == 1){
if(G <= previous_of_past_of_G){
G = ((rand()%G-(G))+(previous_of_past_of_G+1));
}else{
G = ((rand()%previous_of_past_of_G-(previous_of_past_of_G))+(G+1));
}
}
}
cout << "(temper == 1){\n" <<
"\tprevious_of_past_of_G > one_past_of_G && one_past_of_G < G \n" << G;
}else if(previous_of_past_of_G < one_past_of_G && one_past_of_G > G){
if(temper_of_previous == -1){
if(temper_of_pastpast == 1){
if(G <= previous_of_past_of_G){
G = ((rand()%G-(G))+(one_past_of_G+1));
}else if(G > previous_of_past_of_G){
G = ((rand()%previous_of_past_of_G-(previous_of_past_of_G))+( one_past_of_G +1));
}
}
}
cout << "(temper == 1){\n" <<
"\tprevious_of_past_of_G < one_past_of_G && one_past_of_G > G \n" << G;
}else if(previous_of_past_of_G > one_past_of_G && one_past_of_G > G){
if(temper_of_previous == 1){
if(temper_of_pastpast == 1){
G = ((rand()%G-(G))+(one_past_of_G+1));
}else{
G = ((rand()%G-(G))+(previous_of_past_of_G+1));
}
}
cout << "(temper == 1){\n" <<"\tprevious_of_past_of_G > one_past_of_G && one_past_of_G > G \n" << G;
}
}
}else if(n < 2){
if(temper == 1){
if(one_past_of_G <= G){
G = ((rand()%one_past_of_G-(one_past_of_G))+(G+1));
}
else if(one_past_of_G > G ){
G = ((rand()%G )+1);
}
cout << "****ing 2 \n";
}else if(temper == -1){
if(one_past_of_G <= G){
G = ((rand()%G )+1);
}else if(one_past_of_G > G ){
G = ((rand()%one_past_of_G-(one_past_of_G))+(G+1));
}
}
//cout << "fuching 2 \n";
}
if((n > 2) && temper == -1){
if(previous_of_past_of_G < one_past_of_G && one_past_of_G < G){
if(temper_of_previous == 1){
for(i = 0; test < G && test > previous_of_past_of_G || i < 6; i++){
test = ((rand()%previous_of_past_of_G-(previous_of_past_of_G))+(G+1));
if(test < G && test > previous_of_past_of_G)
{
G = test;
}
}
}else if(temper_of_previous == -1){
G = ((rand()%one_past_of_G+1));
}
cout << "fuching cold!! 1<2<3\n";
}else if(previous_of_past_of_G > one_past_of_G && one_past_of_G < G){
if(temper_of_previous == 1){
G = ((rand()%one_past_of_G+1));
}else if(temper_of_previous == -1){
for(i = 0; test < previous_of_past_of_G && test > one_past_of_G || i < 6; i++){
test = ((rand()%one_past_of_G-(one_past_of_G))+(previous_of_past_of_G+1));
if(test < G && test > previous_of_past_of_G)
{
G = test;
}
}
}
cout << "fuching cold!! 1>2<3\n";
}else if(previous_of_past_of_G < one_past_of_G && one_past_of_G > G){
if(temper_of_previous == 1){
if(G <= previous_of_past_of_G){
for(i = 0; test < one_past_of_G && test > G || i < 6; i++){
test = ((rand()%G-(G))+(one_past_of_G+1));
if(test < one_past_of_G && test > G){
G = test;
}
}
}else if(G > previous_of_past_of_G){
for(i = 0; test < one_past_of_G && test > previous_of_past_of_G || i < 6; i++){
test = ((rand()%previous_of_past_of_G-(previous_of_past_of_G))+(one_past_of_G+1));
if(test < one_past_of_G && test > G){
G = test;
}
}
}
}
cout << "fuching cold!! 1<2>3\n";
}else if(previous_of_past_of_G > one_past_of_G && one_past_of_G > G){
if(temper_of_previous == -1){
G = (rand() % G) + G;
}
if(temper_of_previous == 1)
for(i = 0; test < one_past_of_G && test > G || i < 6; i++){
test = ((rand()%G-(G))+(one_past_of_G+1));
if(test < one_past_of_G && test > G){
G = test;
}
}
cout << "fuching cold!! 1>2>3\n";
}
}
if(n > 1){
previous_of_past_of_G = one_past_of_G;
temper_of_pastpast = temper_of_previous;
}
one_past_of_G = G;
temper_of_previous = temper;
//cout << "G = " << G;
//cout << "one past of G = " << one_past_of_G << '\n';
//cout << "previous of past of G = " << previous_of_past_of_G << '\n';
}
cout << "k = " << k << "\n\n";
cout << "n = " << n << '\n';
cout << "real = " << real << "\n\n";
return G;
}
```