load of misaligned address 0x000000000002 for type 'const int', which requires 4 byte alignment
递归做全排列出现的问题。
本机vs2008可以正常使用。
网上都是链表节点的next没有置空,
可是我是int[][]数组
mark一下。。
源码如下:
int ** g_ans = NULL;
int g_index = 0;
int** permute(int* nums, int numsSize, int* returnSize) {
int num = 1;
//缺失下面一句导致!!!
g_index = 0;
for(int i = 1;i<=numsSize;++i)
{
num = num * i;
}
g_ans = (int**)malloc(sizeof(int*)*num);
recurPermute(nums,numsSize,0);
*returnSize = g_index;
return g_ans;
}
int recurPermute(int *nums, int numsSize, int index)
{
if(index == numsSize - 1)
{
g_ans[g_index] = NULL;
g_ans[g_index]=(int*)malloc(sizeof(int)*numsS