Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse debug/run issue
Eclipse debug/run issue [message #1760822] Wed, 03 May 2017 10:30 Go to next message
Vikash Sivasubramaniam is currently offline Vikash SivasubramaniamFriend
Messages: 1
Registered: May 2017
Junior Member
/**********************************************************
* AUTHOR : VIKASH KUMAR
* PROJECT : SORTING NUMBERS IN ASCNEDING ORDER
* DATE : 02/05/2017
**********************************************************/

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>


int main()
{
	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);

	int sort[50] = {0};
	int	i=0;
	int	j=0;
	int	k=0;
	int a = 0;
	printf("Enter 10 Numbers");

	for ( i = 0; i < 10; i++ )
	{
		scanf("%d",&sort[i]);
	}

	for ( i = 0; i < 10; i++ )
	{
		printf("%d\n",sort[i]);
	}

	for ( j=0; j < i-1; j++ )
	{
		for ( k=0; k < i-j-1; k++ )
		{
			if(sort[k] < sort[k+1])
		{
			a = sort[k];
			sort[k] = sort[k+1];
			sort[k+1] = a;
		}

	}
	}
	for ( j = 0; j < i; j++ )
	{
		printf("ascending %d\n",sort[j]);
	}

	getch();
    return 0;
}




when I run the above code it executes and in the console window, I could able to see the print f statement Enter 10 Numbers.

But when I debug the above code I get the following in the console window

Enter 10 Numbers46
0
0
0
0
0
0
0
0
0
ascending 46
ascending 0
ascending 0
ascending 0
ascending 0
ascending 0
ascending 0
ascending 0
ascending 0
ascending 0

Ca anyone please help me to resolve why I get the above as output and what's happening with the code?

I tried to add break point and again in the console window I get the following

Enter 10 Numbers=breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0040150c",func="main",file="..\\main.c",fullname="C:\\CPractice\\UsingEclipse\\Ascending\\main.c",line="24",thread-groups=["i1"],times="1",original-location="C:\\\\CPractice\\\\UsingEclipse\\\\Ascending\\\\main.c:24"}

after giving resume(F8) the code is not executing further.
Re: Eclipse debug/run issue [message #1761111 is a reply to message #1760822] Sun, 07 May 2017 02:34 Go to previous messageGo to next message
Chuck Pergiel is currently offline Chuck PergielFriend
Messages: 30
Registered: April 2016
Location: Silicon Forest
Member
You might try removing the calls to setvbuf. I cannot see it being useful here.

Sent from my Commodore-64 via a US Robotics 300 Baud Modem
Re: Eclipse debug/run issue [message #1803149 is a reply to message #1761111] Sat, 23 February 2019 16:07 Go to previous messageGo to next message
Gordon Doughman is currently offline Gordon DoughmanFriend
Messages: 10
Registered: December 2018
Junior Member
Even though this post is nearly two years old, I am having the same problem. I'm using Eclipse Photon Release (4.8.0) Build id: 20180619-1200 on Windows 7 with the MinGW32 gcc suite. If I use the Eclipse I/O console, the code will not pause for input at scanf(). Instead, it just executes through to the end of the code and sometimes displays a "random" value. If I set a breakpoint, sometimes I get the long string describing the breakpoint properties.

As my code below shows, I've tried using setvbuf() to disable the I/O buffering, but it seems to make no difference. The output shown below was with nothing being entered from the keyboard.

If I use an external console (i.e. checking the "Use external console for inferior (open a new console window for input/output)" in the Debug Configurations "Debugger" tab) the code operates properly.

I'm teaching an Intro to C Programming class and this is a real issue. Any help would be greatly appreciated.

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
 int x;

// setvbuf(stdout, NULL, _IONBF, 0);
// setvbuf(stderr, NULL, _IONBF, 0);

 printf("Enter an integer value:\n");
 scanf("%i", &x);
 printf("The number you entered: %i\n", x);

 return EXIT_SUCCESS;
}

Output:

Enter an integer value:
The number you entered: 35


Re: Eclipse debug/run issue [message #1803153 is a reply to message #1760822] Sat, 23 February 2019 18:28 Go to previous messageGo to next message
Chuck Pergiel is currently offline Chuck PergielFriend
Messages: 30
Registered: April 2016
Location: Silicon Forest
Member
I gave up on Eclipse a couple of years ago. It might be wonderful if you can figure out how to use it. For me, it was too cumbersome. I thought what I wanted to do was simple and straight forward, but doing anything with Eclipse required jumping through multiple hoops. Maybe if I had a template that would configure it for what I wanted, it would have been better, but I never got that far. Mostly I spend my time on codingame.com now, or I just use a text editor.

Sent from my Commodore-64 via a US Robotics 300 Baud Modem
Re: Eclipse debug/run issue [message #1803155 is a reply to message #1803153] Sat, 23 February 2019 20:39 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Quote:
If I use an external console. .. the code operates properly.

Sounds like you have a workaround. You don't want to use it?

---

If you're asking what is going on, there are multiple processes with multiple buffers in play.
It can be tricky trying to flush all of them for a prompt.
Each operating system and UI has defaults that would need to be overcome.
I can't currently test any MinGW solutions at the moment so that is my best guess.

Re: Eclipse debug/run issue [message #1803157 is a reply to message #1803155] Sat, 23 February 2019 22:14 Go to previous message
Gordon Doughman is currently offline Gordon DoughmanFriend
Messages: 10
Registered: December 2018
Junior Member
I'll have my class use the workaround, it's just not nearly as convenient as having the console tab at the bottom of the debug perspective while debugging the code. I was just hoping that there might be something I was over looking since this issue has been around for quite a while.

BTW, I didn't mention this in my original post, but this problem doesn't occur on the Macintosh version of Eclipse (same build).
Previous Topic:Setting Up ZMQ libraries to work with eclipse C++
Next Topic:lpc2136 i
Goto Forum:
  


Current Time: Thu Apr 25 06:06:33 GMT 2024

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

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

Back to the top