how can I write a function to swap to different sized string?
void swap2str(char *a, char *b)
{
char *tmp=malloc(strlen(a)+strlen(b)+2);
strcpy(tmp,a);
strcpy(a,b);
strcpy(b,tmp);
free(tmp);
}
One way. This requires that the original strings are each declared as big enough to hold the other -
i.e.,
char a[32]={0x0};
char b[32]={0x0};
strcpy(a, "junk");
strcpy(b,"even more junk");
swap2str(a,b);
thanks jim for the reply
the first method is more promising