'strncpy' vs. 'sprintf'

后端 未结 4 1225
萌比男神i
萌比男神i 2021-01-31 06:01

I can see many sprintf\'s used in my applications for copying a string.

I have a character array:

char myarray[10];
const char *str = \"myst         


        
4条回答
  •  失恋的感觉
    2021-01-31 06:02

    I would not use sprintf just to copy a string. It's overkill, and someone who reads that code would certainly stop and wonder why I did that, and if they (or I) are missing something.

提交回复
热议问题