我通过间隙打印出数组的每个元素
// n - array length
for(x=0; x<n; x++){
printf("%d ", a[x]);
}
它返回我:
1 2 3 4 5 [space here]
如何删除最新的空格(字符)?
最佳答案
for(x=0; x<n; x++){
if(x == n-1)
printf("%d", a[x]); /* Print without space when printing last element */
else
printf("%d ", a[x]);
}
关于c - 如何从 printf 输出中删除最后一个空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28155918/