Re: is the c code in gcc comiled sequentially???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



enggakshat <enggakshat@xxxxxxxxx> writes:

> for the following simple code i thought its obvious that 'hello' is printed
> but that doesnt happen.
> as far as i knew the code is executed sequentially. 
> 
> #include<iostream>
> 
> using namespace std;
> 
> int main()
> 
> {
>  int i=0;
>  cout<<"hello";
>  while(1)
>  {
>   i++;
>  }
> }

This is most likely a buffering issue.  std::cout is normally line
buffered by default, which means that it is only flushed when you
output a newline character.  Try this:
    cout << unitbuf << "hello";

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux