What will print out?
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%sn”,p2);
}
What will print out?
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%sn”,p2);
}
Here's what it prints out on my system:
qq.c: In function ‘main’:
qq.c:3: error: stray ‘\342’ in program
qq.c:3: error: stray ‘\200’ in program
qq.c:3: error: stray ‘\234’ in program
qq.c:3: error: stray ‘\342’ in program
qq.c:3: error: stray ‘\200’ in program
qq.c:3: error: stray ‘\235’ in program
qq.c:3: error: ‘name’ undeclared (first use in this function)
qq.c:3: error: (Each undeclared identifier is reported only once
qq.c:3: error: for each function it appears in.)
qq.c:5: warning: incompatible implicit declaration of built-in function ‘malloc’
qq.c:6: warning: incompatible implicit declaration of built-in function ‘memset’
qq.c:8: warning: incompatible implicit declaration of built-in function ‘printf’
qq.c:8: error: stray ‘\342’ in program
qq.c:8: error: stray ‘\200’ in program
qq.c:8: error: stray ‘\234’ in program
qq.c:8: error: expected expression before ‘%’ token
qq.c:8: error: stray ‘\342’ in program
qq.c:8: error: stray ‘\200’ in program
qq.c:8: error: stray ‘\235’ in program
:-)
If you're going to cut'n'paste code, at least try it out first.
Here's what it prints out when all the compilation errors are removed although I've cleverly encrypted it. If you want the decryption key, send $45 to my Paypal account:
.