#include <stdio.h>
#include <assert.h>
#include <string.h>
#define pos 5
char *left(char *head,char *tail)
{
assert(head&&tail);
while(head<tail)
{
char tmp = *head;
*head = *tail;
*tail = tmp;
head++;
tail--;
}
return head;
}
char *invert(char *p,int l,int len)
{
assert(p);
left(p,p+l-1);
left(p+l,p+len-1);
left(p,p+len-1);
return p;
}
int main ()
{
char s[] = "abcdefghijk";
int len = strlen(s);
invert(s,pos,len);
printf("%s\n",s);
return 0;
}
#include <assert.h>
#include <string.h>
#define pos 5
char *left(char *head,char *tail)
{
assert(head&&tail);
while(head<tail)
{
char tmp = *head;
*head = *tail;
*tail = tmp;
head++;
tail--;
}
return head;
}
char *invert(char *p,int l,int len)
{
assert(p);
left(p,p+l-1);
left(p+l,p+len-1);
left(p,p+len-1);
return p;
}
int main ()
{
char s[] = "abcdefghijk";
int len = strlen(s);
invert(s,pos,len);
printf("%s\n",s);
return 0;
}