Search This Blog

Translate

C simple program to extract substring from a given string

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';


}


C simple program substring,simple string program in c,c simple program example,c simple program with output,c simple program pdf

C Program example List

Google+ Badge