⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 深入理解c指针之三(指针和结构类型的关系)_月虫_lupa开源社区.htm

📁 最全的介绍C语言结构体的使用方法和使用技巧!
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0051)http://www.lupaworld.com/30208/viewspace_16943.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>深入理解C指针之三(指针和结构类型的关系)_月虫_LUPA开源社区</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gbk">
<META content=,LUPA开源社区 name=keywords>
<META 
content="-------------------指针和结构类型的关系-------------------------------------------可以声明一个指向结构类型对象的指针。 例5: structMyStruct {  int a;  int b;  int c; } MyStruct ss={20,30,40};//声,深入理解C指针之三(指针和结构类型的关系)_月虫_LUPA开源社区,LUPA开源社区" 
name=description><LINK title=月虫 
href="http://www.lupaworld.com/30208/action_rss_type_blog.html" 
type=application/rss+xml rel=alternate><LINK id=commonstyle 
href="深入理解C指针之三(指针和结构类型的关系)_月虫_LUPA开源社区.files/space.css" type=text/css 
rel=stylesheet><LINK id=themestyle 
href="深入理解C指针之三(指针和结构类型的关系)_月虫_LUPA开源社区.files/css_30208.cache.css" type=text/css 
rel=stylesheet>
<SCRIPT type=text/javascript>
var siteUrl = "http://www.lupaworld.com";
</SCRIPT>

<SCRIPT language=javascript 
src="深入理解C指针之三(指针和结构类型的关系)_月虫_LUPA开源社区.files/ajax.js" 
type=text/javascript></SCRIPT>

<SCRIPT language=javascript 
src="深入理解C指针之三(指针和结构类型的关系)_月虫_LUPA开源社区.files/common.js" 
type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV id=wrap>
<DIV id=header>
<DIV id=spacename>
<DIV id=xspace-spacename><STRONG>月虫</STRONG> 
<P><A class=xspace-copyurl title=复制地址 
onclick="javascript:setCopy('http://www.lupaworld.com/30208');" 
href="javascript:;">copy</A> <A class=xspace-add2fav title=加入收藏 
onclick="javascript:addBookmark('月虫','http://www.lupaworld.com/30208');return false;" 
href="http://www.lupaworld.com/30208">Bookmark</A> 
http://www.lupaworld.com/30208</P></DIV></DIV>
<DIV id=menu>
<UL id=xspace-menu>
  <LI class=xspace-active><A class=xspace-blog 
  href="http://www.lupaworld.com/30208/spacelist_type_blog.html">日志</A> </LI>
  <LI><A class=xspace-image 
  href="http://www.lupaworld.com/30208/spacelist_type_image.html">相册</A> </LI>
  <LI><A class=xspace-goods 
  href="http://www.lupaworld.com/30208/spacelist_type_goods.html">商品</A> </LI>
  <LI><A class=xspace-file 
  href="http://www.lupaworld.com/30208/spacelist_type_file.html">文件</A> </LI>
  <LI><A class=xspace-link 
  href="http://www.lupaworld.com/30208/spacelist_type_link.html">书签</A> </LI>
  <LI><A class=xspace-friend 
  href="http://www.lupaworld.com/30208/spacelist_type_friend.html">好友</A> </LI>
  <LI><A class=xspace-mybbs 
  href="http://www.lupaworld.com/30208/spacelist_type_bbs.html">我的论坛</A> </LI>
  <LI><A class=xspace-guestbook 
  href="http://www.lupaworld.com/30208/action_viewpro.html">留言本</A> 
</LI></UL></DIV></DIV><!--//显示头部区域-->
<DIV class=xspace-layout1 id=content>
<DIV id=mainarea>
<DIV id=guide>
<UL id=xspace-guide>
  <LI><A class=xspace-spacehome href="http://www.lupaworld.com/30208">空间首页</A> 
  </LI>
  <LI><A class=xspace-ctrlpannel 
  href="http://www.lupaworld.com/spacecp.php?docp=1">空间管理</A> </LI>
  <LI><A class=xspace-sitehome href="http://www.lupaworld.com/">LUPA开源社区</A> 
  </LI>
  <LI><A class=xspace-bbs href="http://www.lupaworld.com/bbs" 
  target=_blank>站点论坛</A> </LI>
  <LI><A class=xspace-post 
  href="http://www.lupaworld.com/spacecp.php?action=spaceblogs&amp;op=add&amp;openwindow=1">添加我的日志</A> 
  </LI></UL></DIV>
<DIV id=announcement>Coding的枯燥,Debug的无奈,Runing的喜悦,循而往复,或许人就是这么成长的。</DIV>
<DIV id=show>
<H1 class=xspace-title>深入理解C指针之三(指针和结构类型的关系)</H1>
<P class=xspace-smalltxt>2007-04-18 01:10:38 / 个人分类:<A 
href="http://www.lupaworld.com/30208/spacelist_type_blog_itemtypeid_603.html">编程思想(C语言)</A> 
</P>
<DIV class=xspace-itemmessage id=xspace-showmessage>
<DIV><FONT size=3><FONT face="Times New Roman">-------------------</FONT><FONT 
face=宋体>指针和结构类型的关系</FONT><FONT 
face="Times New Roman">-------------------------------------------</FONT><SPAN 
style="DISPLAY: none">LUPA开源社区#Zp u_!~ H.}/yR6V-m</SPAN><BR><FONT 
color=#000000><FONT face=宋体>可以声明一个指向结构类型对象的指针。</FONT><FONT 
face="Times New Roman"> </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">:@$^p ge l0</SPAN><FONT size=3><FONT color=#000000><FONT 
face=宋体>例</FONT><FONT face="Times New Roman">5</FONT><FONT face=宋体>:</FONT><FONT 
face="Times New Roman"> </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">~:\b@y"`2? @0</SPAN><FONT face="Times New Roman"><FONT 
size=3><FONT color=#000000>structMyStruct </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">oa$QI:M V|0</SPAN><FONT face="Times New Roman"><FONT 
size=3><FONT color=#000000>{ </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">5p FZ ig8Y0</SPAN><FONT size=3><FONT color=#000000><FONT 
face=宋体> </FONT><FONT face="Times New Roman">int a; </FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区|)o H#^ {</SPAN><BR><FONT size=3><FONT 
color=#000000><FONT face=宋体> </FONT><FONT face="Times New Roman">int b; 
</FONT></FONT></FONT><BR><SPAN style="DISPLAY: none">v_TDP0</SPAN><FONT 
size=3><FONT color=#000000><FONT face=宋体> </FONT><FONT 
face="Times New Roman">int c; </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">oP$lqvNkR0</SPAN><FONT face="Times New Roman"><FONT 
size=3><FONT color=#000000>} </FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区mvEG[+vW['b</SPAN><BR><FONT 
face="Times New Roman"><FONT size=3><FONT color=#000000>MyStruct 
ss={20,30,40};</FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">7u#Be}(qhL0</SPAN><FONT size=3><FONT 
color=#000000><FONT face="Times New Roman">//</FONT><FONT 
face=宋体>声明了结构对象</FONT><FONT face="Times New Roman">ss</FONT><FONT 
face=宋体>,并把</FONT><FONT face="Times New Roman">ss</FONT><FONT 
face=宋体>的三个成员初始化为</FONT><FONT face="Times New Roman">20</FONT><FONT 
face=宋体>,</FONT><FONT face="Times New Roman">30</FONT><FONT 
face=宋体>和</FONT><FONT face="Times New Roman">40</FONT><FONT 
face=宋体>。</FONT><FONT face="Times New Roman"> </FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区 oS }e:r c @E.^</SPAN><BR><FONT 
face="Times New Roman"><FONT size=3><FONT 
color=#000000>MyStruct*ptr=&amp;ss;</FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区`9J9z't B AO</SPAN><BR><FONT size=3><FONT 
color=#000000><FONT face="Times New Roman">//</FONT><FONT 
face=宋体>声明了一个指向结构对象</FONT><FONT face="Times New Roman">ss</FONT><FONT 
face=宋体>的指针。它的类型是</FONT><FONT face="Times New Roman">MyStruct*,</FONT><FONT 
face=宋体>它指向的类型是</FONT><FONT face="Times New Roman">MyStruct</FONT><FONT 
face=宋体>。</FONT><FONT face="Times New Roman"> </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">8lx1G zMD Ht0</SPAN><FONT face="Times New Roman"><FONT 
size=3><FONT color=#000000>int*pstr=(int*)&amp;ss;</FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区k5K ]'v1v g&amp;n</SPAN><BR><FONT size=3><FONT 
color=#000000><FONT face="Times New Roman">//</FONT><FONT 
face=宋体>声明了一个指向结构对象</FONT><FONT face="Times New Roman">ss</FONT><FONT 
face=宋体>的指针。但是它的类型和它指向的类型和</FONT><FONT face="Times New Roman">ptr</FONT><FONT 
face=宋体>是不同的。</FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">7Cr/uZQF0</SPAN><FONT size=3><FONT color=#000000><FONT 
face=宋体>请问怎样通过指针</FONT><FONT face="Times New Roman">ptr</FONT><FONT 
face=宋体>来访问</FONT><FONT face="Times New Roman">ss</FONT><FONT 
face=宋体>的三个成员变量?</FONT><FONT face="Times New Roman"> </FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区}6Ir9XE)|%s(Fb</SPAN><BR><FONT size=3><FONT 
color=#000000><FONT face=宋体>答案:</FONT><FONT face="Times New Roman"> 
</FONT></FONT></FONT><BR><SPAN style="DISPLAY: none">*s AP!GHF0</SPAN><FONT 
face="Times New Roman"><FONT size=3><FONT color=#000000>ptr-&gt;a; 
</FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区DbstY)|]Xz.f'w</SPAN><BR><FONT 
face="Times New Roman"><FONT size=3><FONT color=#000000>ptr-&gt;b; 
</FONT></FONT></FONT><SPAN style="DISPLAY: none">LUPA开源社区a)G*@ \)~ 
]</SPAN><BR><FONT face="Times New Roman"><FONT size=3><FONT 
color=#000000>ptr-&gt;c; </FONT></FONT></FONT><BR><SPAN 
style="DISPLAY: none">(D?i[WR9{p)@0</SPAN><FONT size=3><FONT 
color=#000000><FONT face=宋体>  又请问怎样通过指针</FONT><FONT 
face="Times New Roman">pstr</FONT><FONT face=宋体>来访问</FONT><FONT 
face="Times New Roman">ss</FONT><FONT face=宋体>的三个成员变量?</FONT><FONT 
face="Times New Roman"> </FONT></FONT></FONT><SPAN 
style="DISPLAY: none">LUPA开源社区fJ-B,K8m w</SPAN><BR><FONT size=3><FONT 
color=#000000><FONT face=宋体>  答案:</FONT><FONT face="Times New Roman"> 
</FONT></FONT></FONT><SPAN style="DISPLAY: none">LUPA开源社区$P&amp;xbP,V 
m5So$g</SPAN><BR><FONT size=3><FONT color=#000000><FONT 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -