Concatenate with memcpy
问题 I'm trying to add two strings together using memcpy. The first memcpy does contain the data, I require. The second one does not however add on. Any idea why? if (strlen(g->db_cmd) < MAX_DB_CMDS ) { memcpy(&g->db_cmd[strlen(g->db_cmd)],l->db.param_value.val,strlen(l->db.param_value.val)); memcpy(&g->db_cmd[strlen(g->db_cmd)],l->del_const,strlen(l->del_const)); g->cmd_ctr++; } 回答1: size_t len = strlen(l->db.param_value.val); memcpy(g->db_cmd, l->db.param_value.val, len); memcpy(g->db_cmd + len,