65,210
社区成员
发帖
与我相关
我的任务
分享[Quote=引用 1 楼 binghuazh 的回复:]
string str ="我们都是学程序的";
char tmp[3];
for(int i = 0;i <str.size();i += 2)
{
tmp[0] = str[i];
tmp[1] = str[i+1];
tmp[2] = '\0';
cout < <tmp < <endl;
}
gl
[/Quote]
////////这个最直接................
char *p="我\n们\n都\n是\n学\n程\n序\n的\n"
cout < <p < <endl;
const char *pBuffer = "我们都是学程序的";
for(size_t i=0; i<strlen(pBuffer); i+=2)
{
printf("%c%c\n", pBuffer[i],pBuffer[i+1]);
}