﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-专注于C,C++,VC,PYTHON等技术-最新评论</title><link>http://www.cppblog.com/guan98413/CommentsRSS.aspx</link><description>There should be one-- and preferably only one --obvious way to do it.</description><language>zh-cn</language><pubDate>Tue, 30 Dec 2008 13:47:57 GMT</pubDate><lastBuildDate>Tue, 30 Dec 2008 13:47:57 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: printf都做了什么？？[未登录]</title><link>http://www.cppblog.com/guan98413/archive/2008/05/01/47530.html#48600</link><dc:creator>lynn</dc:creator><author>lynn</author><pubDate>Thu, 01 May 2008 10:51:00 GMT</pubDate><guid>http://www.cppblog.com/guan98413/archive/2008/05/01/47530.html#48600</guid><description><![CDATA[starofrainnight说的很对；正如楼主所述，stack使用是由高向低进行的。而您代码中描述的：<br>char szMessage[100];<br>strcpy(szMessage, &quot;this is just a test!\n&quot;);<br>数组Message是如此之大，而使用却如此之小，仅&quot;this is just a test!\n&quot;几个字符。这样，存储szMessage时从低址向高址进行，100-22=78个字节尚未使用，退出GetString函数之后。sp指针复原至调用GetString之前的位置。而调用GetPerson的活动记录太小，以至于没有破坏szMessage中存储的22个字符。所以，...<br><img src ="http://www.cppblog.com/guan98413/aggbug/48600.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/guan98413/" target="_blank">lynn</a> 2008-05-01 18:51 <a href="http://www.cppblog.com/guan98413/archive/2008/05/01/47530.html#48600#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: printf都做了什么？？</title><link>http://www.cppblog.com/guan98413/archive/2008/04/19/47530.html#47627</link><dc:creator>starofrainnight</dc:creator><author>starofrainnight</author><pubDate>Sat, 19 Apr 2008 14:03:00 GMT</pubDate><guid>http://www.cppblog.com/guan98413/archive/2008/04/19/47530.html#47627</guid><description><![CDATA[這是初學者很容易犯錯誤，想當年我初學C++時也是對這個問題覺得很奇怪。<br><br>首先，把棧指針傳遞出來是原則性錯誤，在C++裡是不允許的，而在函數結束後讀取該指針指向的內容的行為是未知的。<br>其次，棧內存是在函數開始執行時進行分配，在函數結束進行釋放的。<br>再次，棧內容在函數結束是不會被清理的，因為釋放了的內存不需要再去清理。<br><br>但正因為沒有進行清理，在調用此函數後，你馬上讀取該內存，在大部分情況下是可以讀取到原來的內容的，只要沒有其它的程序使用到該塊內存，那些內容是不會改變的，但這種操作是錯誤的，因為該塊內存已經被釋放了，你所讀取的是已經被釋放了的內存的內容。<br><br>根據各種編譯器的編譯結果不同，根據系統需要不同，根據你程序編寫的不同，你這個函數所產生的結果是不可預料的，如上，後果自負。<img src ="http://www.cppblog.com/guan98413/aggbug/47627.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/guan98413/" target="_blank">starofrainnight</a> 2008-04-19 22:03 <a href="http://www.cppblog.com/guan98413/archive/2008/04/19/47530.html#47627#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: printf都做了什么？？</title><link>http://www.cppblog.com/guan98413/archive/2008/04/19/47530.html#47556</link><dc:creator>啸天猪</dc:creator><author>啸天猪</author><pubDate>Fri, 18 Apr 2008 17:01:00 GMT</pubDate><guid>http://www.cppblog.com/guan98413/archive/2008/04/19/47530.html#47556</guid><description><![CDATA[所谓stack自动清理的意思是：函数调用前后调整栈指针（SP）的任务编译器会自动帮你完成<br><br>至于指向栈中位置的指针，当然可以随便用，不过这和把指针指向内存位置0一样，后果自负<br><br>程序的运行结果无法证明程序的正确性<img src ="http://www.cppblog.com/guan98413/aggbug/47556.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/guan98413/" target="_blank">啸天猪</a> 2008-04-19 01:01 <a href="http://www.cppblog.com/guan98413/archive/2008/04/19/47530.html#47556#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: printf都做了什么？？</title><link>http://www.cppblog.com/guan98413/archive/2008/04/18/47530.html#47549</link><dc:creator>lonkil</dc:creator><author>lonkil</author><pubDate>Fri, 18 Apr 2008 14:52:00 GMT</pubDate><guid>http://www.cppblog.com/guan98413/archive/2008/04/18/47530.html#47549</guid><description><![CDATA[你到Release下看看．再用GCC编译一下试试．<br><br>我试了这几种情况运行结果都不一样．<br><br>说明这种用法存在问题，与printf无关．<br><br>应该heap或在调用函数里把空间分配好，传给子函数赋值．<img src ="http://www.cppblog.com/guan98413/aggbug/47549.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/guan98413/" target="_blank">lonkil</a> 2008-04-18 22:52 <a href="http://www.cppblog.com/guan98413/archive/2008/04/18/47530.html#47549#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: printf都做了什么？？[未登录]</title><link>http://www.cppblog.com/guan98413/archive/2008/04/18/47530.html#47538</link><dc:creator>steven</dc:creator><author>steven</author><pubDate>Fri, 18 Apr 2008 13:16:00 GMT</pubDate><guid>http://www.cppblog.com/guan98413/archive/2008/04/18/47530.html#47538</guid><description><![CDATA[昏。在栈上的数据嘛，肯定没有问题了。<img src ="http://www.cppblog.com/guan98413/aggbug/47538.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/guan98413/" target="_blank">steven</a> 2008-04-18 21:16 <a href="http://www.cppblog.com/guan98413/archive/2008/04/18/47530.html#47538#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>