当前位置: 技术问答>linux和unix
为什么会我调试程序的时候出现“printf.c: 没有那个文件或目录. in printf.c“
来源: 互联网 发布时间:2016-11-13
本文导语: 程序是: #include #include #include typedef struct TAG_datastruct { char *string; int checksum; }datastruct; datastruct *getinput(void); void printmessage(datastruct *todisp); int main(void) { int counter; int maxval = 0; datastruct *svalues[200]; for...
程序是:
#include
#include
#include
typedef struct TAG_datastruct {
char *string;
int checksum;
}datastruct;
datastruct *getinput(void);
void printmessage(datastruct *todisp);
int main(void)
{
int counter;
int maxval = 0;
datastruct *svalues[200];
for (counter = 0; counter string = strdup(input);
instruct->checksum = 0;
for (counter = 0; counter string); counter++) {
instruct->checksum += instruct->string[counter];
}
return instruct;
}
void printmessage(datastruct *todisp)
{
printf("This structure has a checksum of %d. Its stringis:n",
todisp->checksum);
puts(todisp->string);
}
调试的时候:
gcc -ggdb3 -Wall -o test test.c
./test
Enter a string, or leave blank when done:Hello
Enter a string, or leave blank when done:This is the second line.
Enter a string, or leave blank when done:This is the third.
Enter a string, or leave blank when done:gdb is interesting
Enter a string, or leave blank when done:Hmm...!
Enter a string, or leave blank when done:
This structure has a checksum of 1630. Its stringis:
This is the third.
gdb test
(gdb) break main
Breakpoint 1 at 0x8048581: file 2.c, line 16.
(gdb) run
Starting program: /home/zmj/stu/myself/linuxC/test
Breakpoint 1, main () at 2.c:16
16 int maxval = 0;
(gdb) s
19 for (counter = 0; counter
#include
#include
#include
typedef struct TAG_datastruct {
char *string;
int checksum;
}datastruct;
datastruct *getinput(void);
void printmessage(datastruct *todisp);
int main(void)
{
int counter;
int maxval = 0;
datastruct *svalues[200];
for (counter = 0; counter string = strdup(input);
instruct->checksum = 0;
for (counter = 0; counter string); counter++) {
instruct->checksum += instruct->string[counter];
}
return instruct;
}
void printmessage(datastruct *todisp)
{
printf("This structure has a checksum of %d. Its stringis:n",
todisp->checksum);
puts(todisp->string);
}
调试的时候:
gcc -ggdb3 -Wall -o test test.c
./test
Enter a string, or leave blank when done:Hello
Enter a string, or leave blank when done:This is the second line.
Enter a string, or leave blank when done:This is the third.
Enter a string, or leave blank when done:gdb is interesting
Enter a string, or leave blank when done:Hmm...!
Enter a string, or leave blank when done:
This structure has a checksum of 1630. Its stringis:
This is the third.
gdb test
(gdb) break main
Breakpoint 1 at 0x8048581: file 2.c, line 16.
(gdb) run
Starting program: /home/zmj/stu/myself/linuxC/test
Breakpoint 1, main () at 2.c:16
16 int maxval = 0;
(gdb) s
19 for (counter = 0; counter