以下の私のコードで何が間違っていますか?
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;
}