I am very much new to C coding. Just started learning for about one month. Everything was going smoothly but then suddenly DEV C++ started acting strangely. The problem is that now it doesn’t show variable values. That means I write a C code, compile it and after running the program i see what i put in the code is not showing correctly. It was okay a few days ago but now i don’t know how or what cause it is totally screwed.
Here’s a example of the problem. A very simple basic C code. But the end result is messed up.
#include <stdio.h>
main()
{
char a = 'J';
int x = 15;
float y = 9.75;
printf("%c\n%d\n%f", &a,&x,&y);
getch();
}
Output: shows something like a triangle
2293528
0.000000
Can anyone tell me what is the problem and how to fix it?
I am desperate. Dev C++ is the only IDE i can understand. I’ve downloaded a couple others but can’t figure them out.
Program: Orwell Dev-C++
Version: 5.3.0.4
Compiler: MinGW GCC 4.7.0 32bit (included with Dev-C++)
You’re feeding the addresses of those variables to a
printf()which has been told to expect the values. This is undefined behaviour.Just do: