Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Debug variables not showing correct values
Debug variables not showing correct values [message #1827378] Wed, 13 May 2020 17:08 Go to next message
Eclipse UserFriend
When I run the following program, I can enter a number and it outputs the same number back. However, when I run the code in Debug mode, the value of 'a' is always 44, regardless if I entered anything in the console or not. The debugger also thinks that a is 44 since it runs the code inside the if statement.

The strange thing is that when I run the program normally, there are no issues and I get the correct output. Is there any way to fix this?



#include <bits/stdc++.h>
using namespace std;

int main() {

int a;
cin >> a;
cout << a;

if (a == 44) {
cout << "test"; // debugger goes to this line
}



return 0;
}
Re: Debug variables not showing correct values [message #1827396 is a reply to message #1827378] Thu, 14 May 2020 01:17 Go to previous messageGo to next message
Eclipse UserFriend
The debugger doesn't think anything.
It reports what the program does.
I ran your code and got the expected output.

Debugging and typed in "4321\n" and got
!!!Hello World!!!
4321
4321

Running and typing "5467\n":
!!!Hello World!!!
5467
5467


//#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

	int a;
	cin >> a;
	cout << a;

	if (a == 44) {
	cout << "test"<< endl; // debugger goes to this line
	}
	return 0;
}

[Updated on: Thu, 14 May 2020 01:32] by Moderator

Re: Debug variables not showing correct values [message #1827454 is a reply to message #1827396] Thu, 14 May 2020 15:06 Go to previous message
Eclipse UserFriend
Can you post a screen capture of the situation?
Previous Topic:how can i modify the Syntax highlighting color of "internal editors"?
Next Topic:Multiple errors in Sizeof 2d Array Project
Goto Forum:
  


Current Time: Tue Apr 29 01:28:42 EDT 2025

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

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

Back to the top