This code compiles fine, but when I try to run it, it fails.
int main(int argc, char** argv) {
int c = 4;
int b = 5;
int a = a & b;
printf(a);
return (EXIT_SUCCESS);
}
What am I doing wrong?
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.
The first argument to
printfis the format string, achar*. Read this for more information about constructing the format string.should be:
Otherwise
awill be treated as the address of the start of a string, and cause undefined behaviour when it’s dereferenced (there’s a good chance it’ll crash).Also, I’m assuming that the above code isn’t the exact code you’re talking about, since it won’t compile as it is.