Breakpoint 1, main () at time.c:19 19 char *buf=NULL; (gdb) s 20 get_datetime(buf); (gdb) s get_datetime (buffer=0x0) at time.c:7 7 struct tm *ptr= NULL ; (gdb) s 8 time_t lt= 0 ; (gdb) s 10 lt=time(NULL); (gdb) s 11 ptr= localtime(<); (gdb) s 12 strftime(buffer,15,"%Y%m%d%H%M%S",ptr); (gdb) s 13 return 1; (gdb) p buffer $1 = 0x0 (gdb) s 14 } (gdb) s main () at time.c:21 21 printf("[%s]\n",buf); (gdb) s [(null)]
Breakpoint 1, main () at time.c:19 19 char buf[15]={0}; (gdb) s 20 get_datetime(buf); (gdb) s get_datetime (buffer=0xbfffe470 "") at time.c:7 7 structtm* ptr =NULL; (gdb) s 8 time_t lt = 0 ; (gdb) s 10 lt =time(NULL); (gdb) s 11 ptr =localtime(<); (gdb) s 12 strftime(buffer,15,"%Y%m%d%H%M%S",ptr); (gdb) s 13 return 1; (gdb) p buffer $1 = 0xbfffe470 "20071018105524" (gdb) s 14 } (gdb) p buf $2 = 0 (gdb) s main () at time.c:21 21 printf("[%s]\n",buf); (gdb) p buf $3 ="20071018105524" (gdb) s [20071018105524] 22 }