C语言 将字符串反向输出
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void reverse(char *arr
)
{
int temp
, i
;
int len
;
len
= strlen(arr
);
for( i
= 0; i
< len
/ 2; i
++)
{
temp
= arr
[i
];
arr
[i
] = arr
[len
- i
- 1];
arr
[len
- i
- 1] = temp
;
}
}
int main(void)
{
char s
[10] = "abcdefg";
int i
;
reverse(s
);
puts(s
);
system("pause");
return 0;
}
转载请注明原文地址:https://tech.qufami.com/read-20934.html