Trace/BPT trap: 5 problem in m1 mac

hey i am getting a Trace/BPT trap: 5 error in a simple c language code. i am concatenating 2 strings. please if anyone knows help. the code is below:

#include <stdio.h> #include <string.h> int main() { char x[10]= "hello"; char y[10]= "world"; strcat(x, y); printf("%s", x);

}

its a beginner code and i think its not picking up the library

I'm pretty sure the reason this is happening is because you are trying to put the string "helloworld" into x. x has room for 10 chars, "helloworld" requires 11, because strcat wants to put the terminating null into the destination too. You can right-click on strcat and choose Services/Open man page in Terminal from the contextual menu to read about the correct use of strcat.

Trace/BPT trap: 5 problem in m1 mac
 
 
Q