Not couting from within a member function

I guess a better way to phrase this is the cout stream is not flushing from within a member function, although I am using endl. However if I call
 
exit(SomeErrorCode);

from within the said function, but after the line with the cout statement, the cout stream is flushed as expected. When placed at the end of the function (with no exit() ) the debugging cout statement is encounted, but ignored, then program halts before returning from the function.

so i.e.

if I call from my main program:
1
2
MyInstanceOfMyClass.MyFunction();
exit(700);

and MyFunction:
1
2
3
4
5
6
void MyCass::MyFunction()
{
   //yada yada yada
   cout << "This is a debugging statement.  \n" << endl; 
   exit(701);
}

Output will show:

This is a debugging statement

Process returned 701 (0x14)   execution time : 0.109 s


But if I remove the line exit(701); output will not show the debugging statement, nor will it return 700 either. somehow it gets hung up returning from MyFunction, and some how this error is causing a space/time anamoly by retroactivly interrfering with code before the error was encounted.

Please help. I'm starting to get fed up. LOL...




edit: its probably because its happening on the 3rd call to the function... sorry my bad I will look more into it.



Last edited on
Topic archived. No new replies allowed.