how we can replace char with a string
example
char *a="a.s"
so finally
what i ant to do
raplace a with ant and s sree
so in my array a i want to store the value as "ant.sree"
thank u in advance
char *a="a.s"
is constant, you cannot change it.
char dest[24]={0x0};
char src[24]={0x0};
char *p=NULL, *q=NULL;
for(p=src,q=dest; *p; p++)
{
if(*p=='a')
{
strcpy(q,"ant");
q=strchr(q,'\0');
continue;
}
if(*p=='s')
{
strcpy(q,"sree")
q=strchr(q,'\0');
}
else
*q++ = *p;
}
printf("%s\n", dest);