📄 c84.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>概要 </title>
<script language="javascript">
var prePage="http://www.nec.sjtu.edu.cn/support/Course/C/c/c8/c/c8/c83.htm";
var nextPage="c/c9/c91.htm";
function showwin(url,winname,properties){
window.open(url,winname,properties)
}
</script>
<link rel="stylesheet" href="../cstyle.css" type="text/css">
</head>
<body background="../img/mainback.jpg" bgproperties="fixed">
<h2 align="center"><font face="楷体_GB2312">8.4 概要</font></h2>
<hr>
<blockquote>
<p>你学到了什么: <ul>
<li>什么是union ? union 是 C 语言的又一种数据类型。
它允许几个不同类型的不同变量共享同一存储区域。</li>
<li>怎么定义联合? <br>
<font color="#000080">union mixed<br>
{<br>
char c;<br>
float f;<br>
int i;<br>
};</font></li>
<li>怎样说明联合变量? <br>
<font color="#000080">union mixed x;<br>
union mixed *mix_p</font>;</li>
<li>怎样引用联合成员 ?<br>
<font color="#000080">mix.c = 'a';<br>
mix_p->i = 3;</font></li>
<li>什么是 sizeof 运算符 ?sizeof 算符计算指定项目的实际大小(字节数)。</li>
<li>怎样定义枚举数据类型 ?<br>
<font color="#000080">enum location { south, north, east,west };</font></li>
<li>怎样说明枚举类型的变量 ? <br>
<font color="#000080">enum location the_place;</font> </li>
<li>怎样使用枚举变量 ? <br>
<font color="#000080">the_place = east; </font></li>
<li>怎样定义位段结构 ?<br>
<font color="#000080">struct flags<br>
{<br>
unsigned int f1:1;<br>
unsigned int f2:1;<br>
unsigned int f3:1;<br>
};</font></li>
<li>怎样说明一个 flags 类型 ? <br>
<font color="#000080">struct flags flag1; </font></li>
<li>怎样引用位段成员 ? <br>
<font color="#000080">flag1.f1 = 1;<br>
n = flag1.f2;</font></li>
</ul>
</blockquote>
<p align="center"><a href="http://www.nec.sjtu.edu.cn/support/Course/C/c/c9/c91.htm"><img src="../img/next.gif" width="145"
height="30" alt="next.gif (3633 bytes)" border="0"></a></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -