C语言结构体变量成员之指针变量成员的坑

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>


typedef struct input_terminai_Des
{
    int length;
    int soureid;
    int*bmControl;
    int input_termina_type;
}Input_terminai_Des_TY;


static Input_terminai_Des_TY    g_usbinputtermial;
static Input_terminai_Des_TY*   p_usbinputtermial;


static void jiffes(void)
{


}



//0-8 ?
int main()
{

    int*bmControl = NULL;
    bmControl = g_usbinputtermial.bmControl;
    printf("bmControl is %p g_usbinputtermial.bmControl is %p\n",bmControl,g_usbinputtermial.bmControl);
    p_usbinputtermial = (Input_terminai_Des_TY* )malloc(sizeof(*p_usbinputtermial));
    printf("p_usbinputtermial->bmControl is %p\n",p_usbinputtermial->bmControl);
    p_usbinputtermial->bmControl[0] = 1;
    free(p_usbinputtermial);
    // HZ
    bmControl[0] = 1;
    printf("%d\n",bmControl[0]);
    //jiffes(void);  // »á±¨Óï·¨´íÎó
    jiffes();
    for(;;);
    return 0;
}

  

posted @ 2020-10-17 08:08  卷哭你  阅读(189)  评论(0编辑  收藏  举报