int arr [] = {2,54,87,9,132,6}; 我希望将并排数字转换为C中的单个字符串。
like 2, 54 ==>converted into 254
87,9 ==>converted into 879
132,6 ==>converted into 1326
答案 0 :(得分:0)
执行以下操作:
for(i=0; i<n; i+=2) {
char s1[20], s2[20];
sprintf(s1, "%d", a[i]);
sprintf(s2, "%d", a[i+1]);
strcat(s1, s2);
}