Hi pgo,
Thanks for taking a look at my post... I will try to be more specific this time. The major problem I am facing is that I am not able to use printf() statements to correctly print the value of a variable or scanf() to get user input for the value. For example, in the code :
#include <stdio.h>
int main(void)
{
int correct_ans = 53;
int user_ans;
printf("Enter an integer between 1 and 100 as guess :");
scanf("%d", &user_ans);
printf("The number entered by the user is : %d", &user_ans);
if(user_ans == correct_ans)
{
printf("Correct!");
}
else
{
printf("Wrong!");
}
return 0;
}
The value of the variable user_ans shows some large value(536935188) at every step of the code execution in the debugger's "register values" pane. The same value is printed to the console when the printf() is executed. However, if this code is modified to hard-code the variable values like
#include <stdio.h>
int main(void)
{
int correct_ans = 53;
int user_ans = 53;
if(user_ans == correct_ans)
{
printf("Correct!");
}
else
{
printf("Wrong!");
}
return 0;
}
it works, and at every step, the variable values(53) shown are as expected. I suppose then, that there is a problem with the way printf() and scanf() are working ? If so, I am not sure how to read and write register values to the console correctly...