Subscribe Us

Responsive Advertisement

Advertisement

problem 18(extract a substring from given string)

 


//problem 18(extract a substring from given string)


#include<stdio.h>

int main()

{

    int position,length,i,j;

    printf("Enter your string : ");

    char strings[100],extract[100];

    gets(strings);

    printf("Enter position : ");

    scanf("%d",&position);

    printf("Enter length : ");

    scanf("%d",&length);

    position--;

    i=0;

    while(i<length)

    {

        extract[i]=strings[i+position];

        i++;


    }

    printf("Extract string : %s\n",extract);

    return 0;

}


Post a Comment

0 Comments