So I'm starting with using GDB. I'm trying out simple things to get used to it.
So I have the following code with a small bug in it. (Segmentation fault):
char *concat(char *s, char *t){
return strcpy(s+strlen(s), t);
}
int main() {
char *a = "Pliz, ";
char *b = "Help me SoF";
printf("%s + %s = %s\n", a, b, concat(a, b));
return 0;
}
So it gives me a Segmentation fault.
When running gdb main core
, and backtrace bt
to display the program stack I get three frames. When looking at frame 1 of function concat()
, I should see the two parameters s
and t
and their values. But I dont get to see it, How come? What I want is the following as in the picture (See desired result/view; The concat1.c is the same as main.c in my case).