snprintf vs. strcpy (etc.) in C

后端 未结 7 1813
长发绾君心
长发绾君心 2021-01-02 07:35

For doing string concatenation, I\'ve been doing basic strcpy, strncpy of char* buffers. Then I learned about the snprintf and friends

7条回答
  •  青春惊慌失措
    2021-01-02 08:19

    snprintf is more robust if you want to format your string. If you only want to concatenate, use strncpy (don't use strcpy) since it's more efficient.

提交回复
热议问题