How do I concatenate const/literal strings in C?

I’m working in C, and I have to concatenate a few things.

Right now I have this:

message = strcat("TEXT ", var);

message2 = strcat(strcat("TEXT ", foo), strcat(" TEXT ", bar));

Now if you have experience in C I’m sure you realize that this gives you a segmentation fault when you try to run it. So how do I work around that?

17 Answers
17

Leave a Comment