There are no compiler errors but when I run the program and write the two words and the position the program stops and writes this error:
: process returned 255
#include <stdio.h>
#include <stdlib.h>
char strins(char[],char[],int,int,int);
int main(void)
{
char zk1[1000];
char zk2[1000];
int pos=0;
int n1=0;
int n2=0;
printf("plz enter the first string : ");
gets(zk1);
n1=sizeof(zk1)/sizeof(int);
printf("plz enter the second string : ");
gets(zk2);
n2=sizeof(zk2)/sizeof(int);
printf("plz enter the position");
scanf("%d",&pos);
strins(zk1,zk2,pos,n1,n2);
return 0;
}
char strins(char zk1[],char zk2[],int pos,int n1,int n2)
{
char zk3[]={(char)malloc(sizeof(zk1)+sizeof(zk2))};
int ctr=0;
for(int i=0;i<pos;i++)
{
zk3[i]=zk1[i];
ctr++;
}
for(int i=0;i<n2;i++)
{
zk3[pos]=zk2[i];
ctr++;
}
for(int i=pos;i<n1;i++)
{
zk3[ctr]=zk1[i];
}
free(zk3);
return *zk3;
}