simple program to extract sub string from a given string
#include
#include
#include
void extract(char *,char *,char *,int,int);
void main()
{
char s[50]="working with strings is fun";
char t[50];
char d[50];
intpos,len;
printf("enter the position and length to be extracted= ");
scanf("%d%d",&pos,&len);
printf("\n\n");
extract(s,t,d,pos,len);
puts(d);
getch();
}
void extract(char *s,char *t,char *d,intpos,intlen)
{
s=s+(pos-1);
t=s+len;
while(s!=t)
{
*d=*s;
s++;
d++;
}
*d='\0';
}