I ran the following code in codeblocks and got the output:
10 20
10 20
int main()
{
int i=10,j=20;
printf("%d %d\n",i,j);
printf("%d %d",i);
return 0;
}
What is the reason of second 20 ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you’re calling
printfa second time with no intervening code, the value ofjis still on the stack, left from the previous call.Of course, you shouldn’t depend on this behavior. Just because you don’t see the bug doesn’t mean it’s not there. 🙂