Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Console debuging(How may i get messages in-time of debuging?)
Console debuging [message #1715491] Tue, 24 November 2015 04:09 Go to next message
Pavel Petrov is currently offline Pavel PetrovFriend
Messages: 2
Registered: November 2015
Junior Member
Razz
Hi there!

I am totaly newbie in C/C++ code/debug .
So my first question to all of know-how-ers:

how may i get console messages in debuging run-time?

Now i get a couple of test printf() messages only while Windows shutdown the process. Is this is a win-shell feature or gdb feature? Or may be i do something wrong?

Please, help. Very thx
Re: Console debuging [message #1715650 is a reply to message #1715491] Wed, 25 November 2015 02:52 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Your question is not clear but you seem to be asking how to see the output as it occurs.
This generally requires you to set either line buffer mode or unbuffered mode.

My preference is line buffered mode which buffers the output until a newline is transmitted.
To do this:

#include <stdio.h>
setvbuf(stdout, NULL, _IOLBF, 256);

Or fully unbuffered: where each character is output when sent:
#include <stdio.h>
setvbuf(stdout, NULL, _IONBF, 0);

Or you could flush the buffer occasionally using fflush(stdout);

The above are for FILE* objects like stdout. There is a similar function for c++ i/o streams .
see: std::streambuf::pubsetbuf
http://www.cplusplus.com/reference/streambuf/streambuf/pubsetbuf/

[Updated on: Wed, 25 November 2015 03:03]

Report message to a moderator

icon14.gif  Re: Console debuging [message #1715686 is a reply to message #1715650] Wed, 25 November 2015 09:30 Go to previous message
Pavel Petrov is currently offline Pavel PetrovFriend
Messages: 2
Registered: November 2015
Junior Member
you hit the point more than twice!
Very thx! This is exactly what i bother around.
Thank you! Smile
Previous Topic:Linker issues and pkg-config
Next Topic:Cannot get Eclipse for C/C++ to debug
Goto Forum:
  


Current Time: Fri Apr 19 07:14:13 GMT 2024

Powered by FUDForum. Page generated in 0.01856 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top