我下面的代码有什么问题?
当我通过 Dev C++ 编译器编译它时,没有错误或警告。但是在我运行我的程序后,会出现执行错误和以下返回值文本:
进程在 5.1 秒后退出,返回值 3221225477
按任意键继续。. .
知道有什么问题吗?
当我使用调试功能时,该行出现错误:
printf("Value of (*pointerToMyOwnStructPointer)->a = %d\n", (*pointerToMyOwnStructPointer)->a);
我的代码是:
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int a;
int b;
}myIntegers_t;
int main (void)
{
myIntegers_t *myOwnStructPointer = NULL;
myIntegers_t **pointerToMyOwnStructPointer = NULL;
myOwnStructPointer = (myIntegers_t*)malloc(sizeof(myIntegers_t));
if (myOwnStructPointer > 0)
{
myOwnStructPointer->a = 2;
myOwnStructPointer->b = 8;
printf("Value of myOwnStructPointer->a = %d\n", myOwnStructPointer->a);
printf("Value of myOwnStructPointer->b = %d\n", myOwnStructPointer->b);
pointerToMyOwnStructPointer = (myIntegers_t**)myOwnStructPointer;
printf("\n");
printf("Value of (*pointerToMyOwnStructPointer)->a = %d\n", (*pointerToMyOwnStructPointer)->a);
printf("Value of (*pointerToMyOwnStructPointer)->b = %d\n", (*pointerToMyOwnStructPointer)->b);
}
else
{
return -1;
}
return 0;
}