关于Union的问题 [英] About Union's question

查看:88
本文介绍了关于Union的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Union un

{int I;

char c [2];

}


main()

{

union un x;

xc [0] = 10;

xc [1] = 1;

printf("%d",。i);

}

输出结果是什么?请详细说明。

Union un
{ int I;
char c[2];
}

main()
{
union un x;
x.c[0]=10;
x.c[1]=1;
printf("%d",.i);
}
What is the output results? Please explain in detail under.

推荐答案

"í?3?·2" < wa ********* @ gmail.comschrieb im Newsbeitrag

新闻:11 ********************* *@d57g2000hsg.googlegr oups.com ...

#include< stdio.h>
"í?3?·2" <wa*********@gmail.comschrieb im Newsbeitrag
news:11**********************@d57g2000hsg.googlegr oups.com...
#include <stdio.h>

Union un
Union un



union un

union un


{int I;

char c [2];

}
{ int I;
char c[2];
}



};

};


>

main()
>
main()



int main(void)

int main(void)


{

union un x;

xc [0] = 10;

xc [1] = 1;

printf("%d",。i);
{
union un x;
x.c[0]=10;
x.c[1]=1;
printf("%d",.i);



printf("%d \ n",x.I);

返回0;

printf("%d\n",x.I);
return 0;


}


输出结果是什么?请详细说明。
}
What is the output results? Please explain in detail under.



很多编译器错误和一些警告,没有修改

如上所述。修好这些之后,在我的一台机器上输出

是167838688,另一台则是1073807626.

严重依赖于实现和机器架构(大

endian / little endian)


再见,Jojo

Lots of compiler errors and some warnings too, without the modifications
mentioned above. After having fixed these, on one of my machine the output
was 167838688, on another it was 1073807626.
Heavily depends in the implementation and machine architecture (big
endian/little endian)

Bye, Jojo


2007年3月29日23:24:56 - 0700,?????? < wa ********* @ gmail.comwrote:
On 29 Mar 2007 23:24:56 -0700, "??????" <wa*********@gmail.comwrote:

> Union un
{int I;
char c [2];
}


$

union un x;

xc [0] = 10;

xc [1] = 1;

printf("%d",。i);
}

输出结果是什么?请详细说明。
>Union un
{ int I;
char c[2];
}

main()
{
union un x;
x.c[0]=10;
x.c[1]=1;
printf("%d",.i);
}
What is the output results? Please explain in detail under.



该代码甚至不能与我的编译器一起编译,也不应该与你的编译器一起编译。在将代码提交到此新闻组之前,您至少应该努力确保代码编译成

。否则,

这里的任何人都很难为你提供帮助。


祝你好运

-

jay

That code does not even compile with my compilers and should not
compile with yours. You should at least make an effort to insure that
your code compiles before submitting it to this newsgroup. Otherwise,
it can be difficult for anyone here to provide help to you.

Best regards
--
jay


On 3 ??? 30 ??¥,??????????????????????????????????????????????????????????????????????????? < nospam.schm ... @ hp.comwrote:
On 3???30??¥, ??????3???46???, "JoachimSchmitz" <nospam.schm...@hp.comwrote:

" ????????????? < wangchao ... @ gmail.comschrieb imNewsbeitragnews:11 ********************** @ d57g200 0hsg.googlegroups.com ...

#include< stdio.h> Union un

union un
"???μ?3???·?2" <wangchao...@gmail.comschrieb imNewsbeitragnews:11**********************@d57g200 0hsg.googlegroups.com...
#include <stdio.h>Union un
union un

{int I;

char c [2];

}
{ int I;
char c[2];
}



};

};


main()
main()



int main(void)

int main(void)


{

union un x;

xc [0] = 10;

xc [1] = 1;

printf("%d" ,.一世);
{
union un x;
x.c[0]=10;
x.c[1]=1;
printf("%d",.i);



printf("%d \ n",xI);

返回0;}


printf("%d\n",x.I);
return 0;}



非常感谢!我的程序有问题,因为你在右边修正了



#include < stdio.h>

union un

{

int I;

char c [2];

}

int main(无效)

{

union un x;

xc [0] = 10;

xc [1] = 1;

printf("%d",。i);

printf("%d \ n",xI);

返回0;

}

Thank you very much!I have something wrong with the procedure, as you
corrected by the right .

#include <stdio.h>
union un
{
int I;
char c[2];
}
int main(void)
{
union un x;
x.c[0]=10;
x.c[1]=1;
printf("%d",.i);

printf("%d\n",x.I);
return 0;
}


输出结果是什么?请详细说明。
What is the output results? Please explain in detail under.



很多编译器错误和一些警告,没有修改

如上所述。修好这些之后,在我的一台机器上输出

是167838688,另一台则是1073807626.

严重依赖于实现和机器架构(大

endian / little endian)


再见,Jojo


Lots of compiler errors and some warnings too, without the modifications
mentioned above. After having fixed these, on one of my machine the output
was 167838688, on another it was 1073807626.
Heavily depends in the implementation and machine architecture (big
endian/little endian)

Bye, Jojo



然而,我仍然不知道如何编译原理,为什么数字

输出?取决于每个输出的结果有何不同?

However, I still do not know how the compiler theory, Why the digital
output ? Depends what the outcome is different for each output?


这篇关于关于Union的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆