Write a program to extract a portion of a character string and print the extracted string Assume that m?

1 answer

Answer

1091173

2026-04-26 00:56

+ Follow

#include<stdio.h>

#include<string.h>

void main()

{

char str[50];

char ext[50];

int pos,len,i,j=0;

printf("\nenter the main string.....-\n");

gets(str);

printf("\nenter the position and length of the string to be extracted...-\n");

scanf("%d%d",&pos,&len);

for(i=pos-1;i<len+pos;i++)

{

ext[j++]=str[i];

}

puts(ext);

}

/* this is a much easier solution by : ROHIT VERMA*/

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.