33,311
社区成员
发帖
与我相关
我的任务
分享
windows里常见的内存填充数据含义
* 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory
漱 * 0xABADCAFE : A startup to this value to initialize all free memory to catch errant pointers
涵? * 0xBAADF00D : Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory
很? * 0xBADCAB1E : Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger
撅饰 * 0xBEEFCACE : Used by Microsoft .NET as a magic number in resource files
烫烫 * 0xCCCCCCCC : Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory
屯屯 * 0xCDCDCDCD : Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory
葺葺 * 0xDDDDDDDD : Used by Microsoft's free() or delete to mark freed heap memory
蕲蕲 * 0xDEADDEAD : A Microsoft Windows STOP Error code used when the user manually initiates the crash
* 0xFDFDFDFD : Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory
* 0xFEEEFEEE : Used by Microsoft's HeapFree() to mark freed heap memory
#include<stdio.h>
#include <iostream>
#include<stdlib.h>
using namespace std;
const int MaxSize=50;
typedef char ElemType;
typedef struct LNode
{
ElemType data;
struct LNode*next;
} LinkNode;
void InitList(LinkNode*&L)
{
L=new LinkNode;
L->next=NULL;
}
void DestroyList(LinkNode*&L)
{
LinkNode *pre=L,*p=L->next;
while(p!=NULL)
{
delete pre;
pre=p;
p=pre->next;
}
delete pre;
}
bool ListEmpty(LinkNode*L)
{
return(L->next==NULL);
}
int ListLength(LinkNode*L)
{
int n=0;
LinkNode*p=L;
while(p->next!=NULL)
{
n++;
p=p->next;
}
return(n);
}
void DispList(LinkNode*L)
{
LinkNode*p=L->next;
while(p!=NULL)
{
cout<<p->data;
p = p->next;
}
cout<<endl;
}
bool GetElem(LinkNode*L,int i,ElemType&e)
{
int j=0;
LinkNode*p=L;
if(i<=0)return false;
while(j<i&&p!=NULL)
{
j++;
p=p->next;
}
if(p==NULL)
return false;
else
{
e=p->data;
return true;
}
}
int LocateElem(LinkNode*L,ElemType e)
{
int i=1;
LinkNode*p=L->next;
while(p!=NULL&&p->data!=e)
{
p=p->next;
i++;
}
if(p==NULL)
return(0);
else
return(i);
}
bool ListInsert(LinkNode*&L,int i,ElemType e)
{
int j=0;
LinkNode*p=L,*s;
if(i<=0) return false;
while(j<i-1&&p!=NULL)
{
j++;
p=p->next;
}
if(p==NULL)
return false;
else
{
s=new LinkNode;
s->data=e;
s->next=p->next;
p->next=s;
return true;
}
}
bool ListDelete(LinkNode*&L,int i,ElemType&e)
{
int j=0;
LinkNode*p=L,*q;
if(i<=0)return false;
while(j<i-1&&p!=NULL)
{
j++;
p=p->next;
}
if(p==NULL)
return false;
else
{
q=p->next;
if(q==NULL)
return false;
e=p->data;
p->next=q->next;
delete q;
return true;
}
}
main.cpp
#include"linklist.h"
#include<stdio.h>
#include<iostream>
void InitList(LinkNode*&L);
void DestroyList(LinkNode *&L);
bool ListEmpty(LinkNode*L);
void DispList(LinkNode*L);
bool GetElem(LinkNode*L,int i,ElemType&e);
int LocateElem(LinkNode*L,ElemType e);
bool ListInsert(LinkNode*&L,int i,ElemType e);
bool ListDelete(LinkNode*&L,int i,ElemType&e);
int main()
{
LinkNode *h;
ElemType e;
InitList(h);
ListInsert(h,1,'a');
ListInsert(h,2,'b');
ListInsert(h,3,'c');
ListInsert(h,4,'d');
ListInsert(h,5,'e');
DispList(h);
cout<<"(4)单链表h长度为:"<<ListLength(h)<<endl;
printf("(5)单链表h为%s\n",(ListEmpty(h)?"空":"非空"));
GetElem(h,3,e);
cout<<"单链表h的第3个元素是:"<<e<<endl;
cout<<"元素a的位置:"<<LocateElem(h,'a')<<endl;
ListInsert(h,4,'f');
DispList(h);
ListDelete(h,3,e);
DispList(h);
DestroyList(h);
return 0;
}