










char comment[32] = "test#20170420|0420"; char *pos = strchr(comment, '#'); char front[32]={0}; char back[32]={0}; char newComment[32] = {0}; memcpy(front, comment, pos-comment); strcpy_s(back, pos); sprintf_s(newComment, "%sC%s", front, back); std::cout<<newComment<<endl;
任何new内存都是消耗的,正确的做法是使用memcpy
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。