- 论坛徽章:
- 1
|
10可用积分
A.c ,代码如下:
typedef struct _testA
{
char name[100];
char add[100];
} _testA;
int main()
{
_testA *A=NULL;
A=process();
printf("name in main: %s",A->name); -----------1
free(A);
}
B.c,代码如下:
typedef struct _testA
{
char name[100];
char add[100];
char comp[100];
} _testA;
struct _testA * process()
{
_testA *A=(_testA *)malloc(sizeof(_testA));
memset(A,0x00,sizeof(A));
strcpy(A->name,"UNIX");
strcpy(A->add,"UNIX");
strcpy(A->comp,"UNIX");
printf("name in process : %s",A->name); -------2
return A;
}
步骤:
1. B.c生成一个??.a文件
2. 接着A.c生成A.o
3. 最后A.o和??.a生成一个执行文件A
现在运行A 程序,
2打印数据为: UNIX 正确
1居然没打印出数据
注意:A.c和B.c里面A结构的不同....
太强悍了,什么原因呢?
[ 本帖最后由 chenzhanyiczy 于 2009-7-31 21:51 编辑 ] |
|