gdb调试:记得在编译 greeting 程序时把调试选项打开. 其中的"把调试选项打开"如何打开?

用下面的命令编译它:
gcc -o test test.c

这个程序执行时显示如下结果:
The string is hello there
The string printed backward is

输出的第一行是正确的, 但第二行打印出的东西并不是我们所期望的. 我们所设想的输出应该是:
The string printed backward is ereht olleh

由于某些原因, my_print2 函数没有正常工作. 让我们用 gdb 看看问题究竟出在哪儿, 先键入如下命令:
gdb greeting

注意: 记得在编译 greeting 程序时把调试选项打开.

http://tech.ccidnet.com/pub/article/c1060_a116833_p1.html#comment
原文在上面的网址


注意: 记得在编译 greeting 程序时把调试选项打开.
如果在编译greeting程序时把调试选项打开?

qcc -g -o test test.c ,可以参考

http://www.qnx.com/developers/docs/momentics621_docs/neutrino/utilities/q/qcc.html

顺便提醒一下,在UNIX机器上把自已的程序叫"test"常常会引起误动作,因为test是一个shell的命令,也有的系统也提供一个程序叫test。

改 mytest 吧。:smiley: