Concatenating strings in C, which method is more efficient?

后端 未结 10 886
迷失自我
迷失自我 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:36

    Don't worry about efficiency: make your code readable and maintainable. I doubt the difference between these methods is going to matter in your program.

提交回复
热议问题