fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct _scn_flashdev_body_
  4. {
  5. unsigned char scenetype;
  6. unsigned short device;
  7. unsigned short action;
  8. unsigned short reserve;
  9. } scnflashdev_lib;
  10.  
  11. scnflashdev_lib *testtal(void)
  12. {
  13. scnflashdev_lib tab;
  14. scnflashdev_lib *p;
  15.  
  16. tab.scenetype = 1;
  17. tab.device = 3;
  18. tab.action = 1;
  19. tab.reserve = 4;
  20. p = &tab;
  21. // printf("p:%p\r\n",p);
  22. return (p); //指针的地址已经被释放了,错误
  23. }
  24.  
  25.  
  26. int main(void) {
  27. scnflashdev_lib *aa;
  28.  
  29. aa = testtal();
  30. printf("scenetype:%p\r\n",aa);
  31. printf("scenetype:%d,device:%d,action:%d\r\n",aa->scenetype,aa->device,aa->action);
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
scenetype:0x7ffd44252ad0
scenetype:192,device:17445,action:32765