cout not printing while in while loop

This one is really stumping me. Inside this while loop there are a few cout statements which should print something to the screen. Right now the loop is infinite for testing but that is not the issue. while loop snippet below

1
2
3
4
5
6
7
8
9
10
11
12
13
 while(run == 1) 
        {
                curtime = ((float)t)/CLOCKS_PER_SEC;
                startacc = 1;
                if(accstate == 0 && startacc == 1)
                {
                        accstate = 1;
                        acctime = curtime;
                        digitalWrite(s,1);
                        acc_output();
                        //read output data to WiFi
                }
        }


acc_output() function snippet

1
2
3
4
5
6
7
8
9
10
11
12
13
accx = avgacc();
    cout << "X Acceleration: " << accx << " mV\n\n" << flush;
        digitalWrite(A,0);
    digitalWrite(B,0);
    digitalWrite(C,1);
    accy = avgacc();
    cout << "X Acceleration: " << accy << " mV\n\n" << flush;
    digitalWrite(A,0);
    digitalWrite(B,1);
    digitalWrite(C,0);
    accz = avgacc();
    cout << "X Acceleration: " << accy << " mV\n\n" << flush;
        cout << "\x1b[2J\x1b[H" << flush;


The weird thing is I know the program is taking the last line because the screen is being cleared, but still nothing is being printed to the screen. It is just an infinite blank screen. It should print something because accx is initialized to 0.
> I know the program is taking the last line because the screen is being cleared
If you intend to show something to the screen and read it,
then don't clear the screen.
Topic archived. No new replies allowed.