📄 深入理解sizeof.htm
字号:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="深入理解sizeof.files/filelist.xml">
<title>无标题文档</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>FtpDown</o:Author>
<o:Template>Normal</o:Template>
<o:LastAuthor>FtpDown</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>0</o:TotalTime>
<o:Created>2005-10-16T14:56:00Z</o:Created>
<o:LastSaved>2005-10-16T14:56:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>675</o:Words>
<o:Characters>3849</o:Characters>
<o:Company>www.ftpdown.com</o:Company>
<o:Lines>32</o:Lines>
<o:Paragraphs>9</o:Paragraphs>
<o:CharactersWithSpaces>4515</o:CharactersWithSpaces>
<o:Version>11.5606</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:Zoom>127</w:Zoom>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:宋体;
mso-bidi-font-family:宋体;}
p
{font-size:12.0pt;
font-family:宋体;
mso-bidi-font-family:宋体;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="2050"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
</head>
<body lang=ZH-CN style='tab-interval:21.0pt'>
<div class=Section1>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'>
<p class=MsoNormal><span lang=EN-US>http://www.insun.hit.edu.cn/oblog3/user1/13/archives/2005/103.asp </span></p>
</blockquote>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
style='mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
<td style='padding:0cm 0cm 0cm 0cm'>
<p class=MsoNormal>深入理解<span lang=EN-US>sizeof</span>(转载) </p>
</td>
</tr>
<tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
<td style='padding:0cm 0cm 0cm 0cm'>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
style='mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
<td style='padding:0cm 0cm 0cm 0cm'>
<p class=MsoNormal>辉<span lang=EN-US>-></span>春去春来 发表于<span lang=EN-US>
2005-7-9 20:49:05 </span></p>
</td>
</tr>
</table>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
style='mso-cellspacing:0cm;mso-padding-alt:0cm 0cm 0cm 0cm'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>
<td style='padding:0cm 0cm 0cm 0cm'>
<p>最近在论坛里总有人问关于<span lang=EN-US>sizeof</span>的问题,并且本人对这个问题 </p>
<p>也一直没有得到很好的解决,索性今天对它来个较为详细的总结,同 </p>
<p>时结合<span lang=EN-US>strlen</span>进行比较,如果能对大家有点点帮助,这是我最大的欣 </p>
<p>慰了。 </p>
<p> 一、好首先看看<span lang=EN-US>sizeof</span>和<span lang=EN-US>strlen</span>在<span
lang=EN-US>MSDN</span>上的定义: </p>
<p> 首先看一<span lang=EN-US>MSDN</span>上如何对<span lang=EN-US>sizeof</span>进行定义的:
</p>
<p> <span lang=EN-US>sizeof Operator </span></p>
<p> <span lang=EN-US>sizeof expression </span></p>
<p> <span lang=EN-US>The sizeof keyword gives the amount of storage, in
bytes, </span></p>
<p><span lang=EN-US>associated with a variable or a type (including
aggregate types). </span></p>
<p><span lang=EN-US>This keyword returns a value of type size_t. </span></p>
<p> <span lang=EN-US>The expression is either an identifier or a type-cast
expression </span></p>
<p><span lang=EN-US>(a type specifier enclosed in parentheses). </span></p>
<p> <span lang=EN-US>When applied to a structure type or variable, sizeof
returns </span></p>
<p><span lang=EN-US>the actual size, which may include padding bytes
inserted for </span></p>
<p><span lang=EN-US>alignment. When applied to a statically dimensioned
array, sizeof </span></p>
<p><span lang=EN-US>returns the size of the entire array. The sizeof
operator cannot </span></p>
<p><span lang=EN-US>return the size of dynamically allocated arrays or
external </span></p>
<p><span lang=EN-US>arrays. </span></p>
<p> 然后再看一下对<span lang=EN-US>strlen</span>是如何定义的: </p>
<p> <span lang=EN-US>strlen </span></p>
<p> <span lang=EN-US>Get the length of a string. </span></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -