Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - std::cout doesn't print letters after \n: (5 Items)
   
std::cout doesn't print letters after \n  
The following code always outputs:
Item1
Item2


Code:
#include <iostream>
#include <string>

int main() {
  std::string string_test{"Item1\nItem2\nItem3"};
  std::cout << string_test;

  return 0;
}

 Any explanations? Is this a bug?
Re: std::cout doesn't print letters after \n  
at a guess, it's not flushing stdout because Item3 isn't followed by a '\n'. Try adding one and see whether that helps.

(I'm also guessing that you're showing just an excerpt of the actual code that's proving troublesome .. )

regards ..

On Tue, 2019-01-29 at 09:26 -0500, Ilyas Hamadouche wrote:

The following code always outputs:
Item1
Item2


Code:
#include <iostream>
#include <string>

int main() {
  std::string string_test{"Item1\nItem2\nItem3"};
  std::cout << string_test;

  return 0;
}

 Any explanations? Is this a bug?



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post119454
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com<mailto:ostech
-core_os-unsubscribe@community.qnx.com>;

Attachment: HTML sf-attachment-mime37442 1.26 KB
Re: std::cout doesn't print letters after \n  
Thank you Michael for the reply.

I tried flushing but without result. ( Surprisingly std::cerr works just fine even without flush)

Of course there are other ways to print, but the point here is that if this is a bug, we want to report to QNX.

BR,
Ilyas
Re: std::cout doesn't print letters after \n  
What version of QNX are you using? There is a known bug in the handling
of line-buffered stream output in 7.0.3 only, that will be fixed in
7.0.4.

--Elad

On Tue, 2019-01-29 at 09:43 -0500, Ilyas Hamadouche wrote:
> Thank you Michael for the reply.
> 
> I tried flushing but without result. ( Surprisingly std::cerr works
> just fine even without flush)
> 
> Of course there are other ways to print, but the point here is that
> if this is a bug, we want to report to QNX.
> 
> BR,
> Ilyas
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post119456
> To cancel your subscription to this discussion, please e-mail ostech-
> core_os-unsubscribe@community.qnx.com
Re: std::cout doesn't print letters after \n  
Hi Elad,

Thanks for the information. Yes, I am using QNX 7.0.3. 

BR,
Ilyas