Eclipse debug/run issue [message #1760822] |
Wed, 03 May 2017 10:30 |
Vikash Sivasubramaniam 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 #1803149 is a reply to message #1761111] |
Sat, 23 February 2019 16:07 |
Gordon Doughman 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03559 seconds