- 论坛徽章:
- 0
|
- gcc -ggdb -o greeting greeting.c
- [root@test2 /root]# gdb greeting
- GNU gdb 5.0
- Copyright 2000 Free Software Foundation, Inc.
- GDB is free software, covered by the GNU General Public License, and you are
- welcome to change it and/or distribute copies of it under certain conditions.
- Type "show copying" to see the conditions.
- There is absolutely no warranty for GDB. Type "show warranty" for details.
- This GDB was configured as "i386-redhat-linux"...
- (gdb) run
- Starting program: /root/greeting
复制代码
不知道为什么gdb就停在这里不动了,是否gdb工具本身不可用?我的系统是linux7。0。
greeting.c源码:
- #include <stdio.h>;
- void my_print();
- void my_print2();
- main()
- {
- char my_string[] = "hello here.";
- my_print(my_string);
- my_print2(my_string);
- }
- void my_print(char *string)
- {
- printf("The string is %s\n",string);
- }
- void my_print2(char *string)
- {
- char *string2;
- int size , i;
- size = strlen(string);
- string2 = (char *) malloc (size + 1);
- for (i = 0; i < size; i++)
- {
- string2[size-i] = string[i];
- }
- string2[size] = '\0';
- printf ("The string printed backward is %s \n", string2);
- }
复制代码 |
|