#include<stdio.h>
#include<string.h>
void main()
{
char s[] = "tom and jerry";
//char *s = "tom and jerry";如果这样写是不对的。因为*s申请一个全局变量存储空间,是不能改变的
char *i, *j;
i = s;
j = s + strlen(s) - 1;
for ( ; i < j; i++, j--)
{
char c = *i;
*i = *j;
*j = c;
}
puts(s);
}
#include<string.h>
void main()
{
char s[] = "tom and jerry";
//char *s = "tom and jerry";如果这样写是不对的。因为*s申请一个全局变量存储空间,是不能改变的
char *i, *j;
i = s;
j = s + strlen(s) - 1;
for ( ; i < j; i++, j--)
{
char c = *i;
*i = *j;
*j = c;
}
puts(s);
}