我正在编写一个可以递归打印目录的程序,下面是 gdb 调试段
请注意,d_path(它是作为参数传递给 print_dir_tree 的 const char *)在“if (dr == NULL) {”步骤之前是“/home/cifer/.gftp”,但是,它被打印为“/home/ cifer/!\200" 在此子句之后
谁能告诉我为什么?多谢!
Breakpoint 1, print_dir_tree (d_path=0x805b058 "/home/cifer/.gftp", depth=4)
at dir_demo.c:15
15 DIR *dr = opendir(d_path);
(gdb) print d_path
$2 = 0x805b058 "/home/cifer/.gftp"
(gdb) print d_path
$3 = 0x805b058 "/home/cifer/.gftp"
(gdb) step
16 if (dr == NULL) {
(gdb) print d_path
$4 = 0x805b058 "/home/cifer/!\200"
(gdb) step
20 struct dirent *de = NULL;
(gdb) print d_path
$5 = 0x805b058 "/home/cifer/!\200"
(gdb) step
21 while((de = readdir(dr)) != NULL) {
(gdb) print d_path
$6 = 0x805b058 "/home/cifer/!\200"
(gdb)