編程的時候我定義了一個結構體,結構體有幾個變量的值我必須要賦初值,因為循環得用。
結構體這樣定義:
typedef struct
{
BYTE stream_Type;
unsigned short PID;
unsigned short InfoDescrip;
}M_PICE;
用的時候:
M_PICE* p_Mpice = NULL;
p_Mpice->InfoDescrip = 0;
運行到上一句就報錯
Unhandled exception in DVB.exe:0xC0000005:Access Violation
typedef struct pice
{
int stream_Type;
unsigned short PID;
unsigned short InfoDescrip;
}M_PICE;
M_PICE* pMypice;
int main(){
pMypice = (M_PICE*)malloc(sizeof(M_PICE));//此處分配內存空間,否則怎麼存數據、
pMypice->InfoDescrip = 0;
printf("%d\n",pMypice->InfoDescrip);
}
趕緊采納。