燙燙燙燙燙屯屯屯屯

來源:互聯網
上載者:User

#include<iostream>using namespace std;int main(){char *s = (char*)malloc(10);cout<<s<<endl;char p[10];cout<<p<<endl;}


出現以上原因都是由於記憶體沒有初始化造成的,而對於棧中記憶體如果沒有初始化,則會出現“燙燙燙燙燙燙”。對於堆中記憶體如果沒有初始化,則會出現“屯屯屯屯屯”,有時候我們的數組沒有結束符,輸出數組也會有這些漢字的出現,就是因為沒有結束符佔用了後面的閒置記憶體塊即沒有初始化的記憶體塊


=============================

Value     Name           Description  
------   --------        ------------------------- 
0xCD     Clean Memory    Allocated memory via malloc or new but never  
                          written by the application.  
  
0xDD     Dead Memory     Memory that has been released with delete or free.  
                          Used to detect writing through dangling pointers.  
  
0xFD     Fence Memory    Also known as "no mans land." This is used to wrap  
                          the allocated memory (surrounding it with a fence)  
                          and is used to detect indexing arrays out of  
                          bounds or other accesses (especially writes) past 
                          the end (or start) of an allocated block. 
  
0xCC                     When the code is compiled with the /GZ option, 
                          uninitialized variables are automatically assigned  
                          to this value (at byte level).  
  
  
// the following magic values are done by the OS, not the C runtime: 
  
0xAB  (Allocated Block?) Memory allocated by LocalAlloc().  
  
0xBAADF00D Bad Food      Memory allocated by LocalAlloc() with LMEM_FIXED,but  
                          not yet written to.  
  
0xFEEEFEEE               OS fill heap memory, which was marked for usage,  
                          but wasn't allocated by HeapAlloc() or LocalAlloc().  
                          Or that memory just has been freed by HeapFree(). 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.