[英]compare two address, list C
如果我有一個長字符數組[100],其中存儲了一個結構列表,如果我想最后添加一個結構,我如何檢查它是否超出了邊界?
例如,
static char arr[100];
typedef NODE* node_ptr;
typedef struct node
{
char a;
char b;
int size;
node_ptr next;
}NODE;
//arr already contains few node in it.
//size: the new node size, I want to add in the end
node_ptr add_node(node_ptr last, size_t size)
{
node_ptr new;
if(last+2*sizeof(NODE)+size<arr+100)
//add new node
return new;
}
如何檢查新節點是否超出數組邊界?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.