#include <stdio.h>
struct test
{
int a;
int b;
};
struct test *fun1()
{
struct test t;
t.a = 1;
t.b = 2;
return &t;
}
void fun2(struct test *t1, struct test *t2)
{
printf("\nt1->a=%d t1->b=%d, t2->a=%d t2->b=%d\n",t1->a,t1->b,t2->a,t2->b);
return;
}
void main()
{
fun2(fun1(),fun1());
struct test
{
int a;
int b;
};
struct test *fun1()
{
struct test t;
t.a = 1;
t.b = 2;
return &t;
}
void fun2(struct test *t1, struct test *t2)
{
printf("\nt1->a=%d t1->b=%d, t2->a=%d t2->b=%d\n",t1->a,t1->b,t2->a,t2->b);
return;
}
void main()
{
fun2(fun1(),fun1());
}
请根据以上代码回答如下几个问题.
1.sizeof(struct test) = ?
2. 函数调用顺序是否为:main->fun2->fun1->fun1->printf 。如果不是,请给出你认为正正确的顺序。
3.函数main由谁来调用?
4.程序中是否有错误,如果有,请纠正。
5.变量t存放在什么地方?
#include <stdio.h>
struct test
{
int a;
int *p;
};
void main()
{
struct test t;
int *p;
p = &t.a;
p[0] = 1;
p[1] = 2;
t.p = p;
t.p[1] = 3;
t.p[0] = 4;
}
请问以上程序在第几行会出现非法操作?为什么?
#include <stdio.h>
unsigned short v1, v2;
void main()
{
v1 = 0x8000;
v2 = 0x4000;
v1 = (v1 + 32768) >> 15 + 1;
v2 = (v2 + 32768) >> 15 + 1;
printf("v1=%d, v2=%d\n",v1,v2);
}
请写出输出结果?