我有道理吗?这是我想要做的:将整数解释为指向动态字符串的指针,从指向指针的动态块开始
unsigned int *a = 0;
unsigned int **b = &a;
// b -> a -> null
*b = (unsigned int*)malloc(12);
// b -> a -> [xxxx|xxxx|xxxx]
*(*b+1) = (unsigned int)malloc(sizeof("come on!"));
// b -> a -> [xxxx|xxxx|xxxx]
// v
// [xxxxxxxxx]
strcpy((char*)*(*b+1),"come on!"); // FAILS! why?
我不知道我还能描述什么。
你为什么假设指针和整数总是4个字节? –
哈哈哦,男人,我忘了我正在运行一个64位系统。是的,需要8个字节的指针。哎呦!谢谢。 – Shadd
这些数字有什么问题?他们只是简化的可视化。 – Shadd