Hi,
I am trying to run my first C program on Keil...it works perfectly until I insert a printf statement...am i missing something?
#include <reg52.h> #include <stdio.h> void main(void) { unsigned int i; unsigned int ans = 0; for (i =0; i< 5; i++) { ans += 2; } printf("The answer is: " + ans); }
The last instruction does not do anything - you are never using ans before leaving main() so what do you expect the compiler to do?
Another thing: You do not have a command line to return to, so do not write a main() that drops you out into the unknown.
Add an infinite loop at the end of main.