Skip to content

Instantly share code, notes, and snippets.

@adow
Created December 19, 2013 06:12
Show Gist options
  • Save adow/8035101 to your computer and use it in GitHub Desktop.
Save adow/8035101 to your computer and use it in GitHub Desktop.
翻转字符串
void strRev(char *s)
{
char temp, *end = s + strlen(s) - 1;
while( end > s)
{
temp = *s;
*s = *end;
*end = temp;
--end;
++s;
}
}
void strRev(char *s)
{
char temp;
for(char *end = s + strlen(s) - 1; end > s ; --end, ++s)
{
temp = *s;
*s = *end;
*end = temp;
}
}
void strRev(char *s)
{
for(char *end = s + strlen(s) - 1; end > s ; --end, ++s)
{
*s ^= *end;
*end ^= *s;
*s ^= *end;
}
}
void strRev(char *s)
{
for(char *end = s + strlen(s) - 1; end > s ; --end, ++s)
{
*s ^= *end ^= *s ^= *end;
}
}
void strRev(char *s)
{
for(char *end = s + strlen(s) - 1; end > s ; *s++ ^= *end ^= *s ^= *end--);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment