by Dinesh Thakur Category: Array
#include <Stdio.h>

#include <conio.h>
int main()
   char str[100], substr[100];
   int i=0, j=0, n, m;
   clrscr ();
   printf("\n Enter the main string: ");
   gets (str);
   printf("\n Enter the position from which to start the substring: ");
   scanf ("%d", &m) ;
   printf("\n Enter the length of the substring: ") ;
   scanf ("%d", &n);
   while(str[i] !='\0' &&n>=0)
     substr[j] = str[i];
     j ++;
      substr[j] = '\0';
      printf ("\n The substring is : ");
      puts (str);
    return 0;

extract the substring from a given string

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles