分类: C/C++
2011-12-13 21:49:42
#include"string.h"
main()
{
const char* src = "hello world";
int len = strlen(src);
char* dest = (char*)malloc(len+1);
char* d = dest;
char* s = src[len-1];
while( len-- ! = 0)
{
*d++ = *s--;
}
*d = 0;
printf("%s", dest);
free(dest);
return 0;
}
#include"stdio.h"
#include"string.h"
main()
{
char a[] = "hello,world";
int len = strlen(str);
char t;
for(int i=0; i<=len/2; i++)
{
t = str[i];
str[i] = str[len-i-1];
str[len-i-1] = t;
}
printf("%s",str);
return 0;
}