strcat() for formatted strings

前端 未结 6 1455
予麋鹿
予麋鹿 2021-02-20 05:37

I\'m building a string piece by piece in my program and am currently using a mix of strcat() when I\'m adding a simple string onto the end, but when im adding a formatted string

6条回答
  •  忘掉有多难
    2021-02-20 06:08

    no it's not possible but you could use sprintf() on those simple strings and avoid calling strlen() every time:

    len = 0;
    len += sprintf(buf+len, "%s", str);    
    len += sprintf(buf+len, " number %d", one);
    

提交回复
热议问题