#include <stdio.h> #include <stdlib.h> void test() { char buffer[1024]={0}; char* mem=(char*)calloc(sizeof(char)*1024,1); char* p1=&buffer[0]; char* p2=mem; size_t len_p0=sizeof(buffer); size_t len_p1=sizeof(p1); size_t len_p2=_msize(p2)/sizeof(char); function_about_pointer_at(p1,p2); printf("length of local function frame stack:%d\n",len_p0); printf("length of local variable itself:%d\n",len_p1); printf("length of heap memory:%d\n",len_p2); } void function_about_pointer_at(char* p1,char* p2) { //if there is no coding context, is it possible to figure out about p1/p2 , which is pointed at a frame stack memory, // which is pointed at a heap memory ? //... } void main() { test(); }
Randor
main
p1
p2
malloc
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)