| /*I revised my programe ,corrected the error of the usage of "strcat".
still I can`t pass the compiling .
would someone post the code that can be compiled correctly .
your help will be well appreciated .
the code i given below */
#include<stdio.h>
#include<string.h>
int L;
void insort(int n,char s[],char c[]);
void insort(int n,char s[],char c[])
{
char d[50];
char str1[50],*str2;
int i;
if(n==0) s[n]=c[n];
else{ for(i=n;i>=0;i--)
{ memcpy(d,s,strlen(s));
d[strlen(s)]='\0';
memcpy(str1,d,i);
str1[i]='\0';
str2=d+i;
strcat(str1,c[n]);
strcat(str1,str2);
//d=str1;
memcpy(d,str1,strlen(str1));
d[strlen(str1)]='\0';
if (n==L)printf("%s\n",d);
}
}
if (n+1<=L)
insort(n+1,s,c);
}
int main()
{ char str[1000];
str[0]='\0';
char S[]="abcd";
L =strlen(S);
insort(0,str,S);
return 0;
} |