#include <stdio.h>
#define MAX_SIZE 100
int main()
{
int i;
int num;
int len;
char temp;
char src[MAX_SIZE];
printf("Please input number:\n");
scanf("%d",&num);
i = 0;
while(num != 0)
{
src[i] = (num % 10) + '0';
num = num / 10;
i++;
}
src[i] = '\0';
len = strlen(src);
for(i = 0; i < len / 2; i++)
{
temp = src[i];
src[i] = src[len - i - 1];
src[len - i - 1] = temp;
}
printf("src = %s\n",src);
return 0;
#define MAX_SIZE 100
int main()
{
int i;
int num;
int len;
char temp;
char src[MAX_SIZE];
printf("Please input number:\n");
scanf("%d",&num);
i = 0;
while(num != 0)
{
src[i] = (num % 10) + '0';
num = num / 10;
i++;
}
src[i] = '\0';
len = strlen(src);
for(i = 0; i < len / 2; i++)
{
temp = src[i];
src[i] = src[len - i - 1];
src[len - i - 1] = temp;
}
printf("src = %s\n",src);
return 0;
}
/* len = strlen(src);
for(i = 0; i < len / 2; i++)
{
temp = src[i];
src[i] = src[len - i - 1];
src[len - i - 1] = temp;
} */
逆序一个字符串