70,032
社区成员




What will print out?
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%s\n”,p2);
}
Answer:empty string.
What will be printed as the result of the operation below:
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);
}
Answer : 5794
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int main()
{
char *p1="name";
char *p2;
p2=(char*)malloc(20);
memset (p2, 1, 20);
while(*p2++ = *p1++);
printf("%s\n",p2);
return 0;
}
#include<stdio.h>
main()
{
int x = 20, y = 35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %dn", x, y);
}
这个程序是这样运行的:
x = y++ + x++;首先是x=20与y=35相加后x=55,并且x y都要自加 所以x=56,y=36
y = ++y + ++x;首先是x y都自加,x=57,y=37,然后x+y得y=94
这个题没有问题