Concatenating strings in C, which method is more efficient?

后端 未结 10 931
迷失自我
迷失自我 2020-11-28 19:51

I came across these two methods to concatenate strings:

Common part:

char* first= \"First\";
char* second = \"Second\";
char* both = malloc(strlen(fi         


        
10条回答
  •  庸人自扰
    2020-11-28 20:42

    They should be pretty much the same. The difference isn't going to matter. I would go with sprintf since it requires less code.

提交回复
热议问题