C program to extract a portion of string (Substring Extracting in C)
In this program, we are taking a string from the user and extracting the substring (a portion of the string). To get the substring from the string, we are taking from and to (start and end) index.
Here, we are implementing a user defined function named getSubString(), this function will take following four arguments and return either 0 (on successful execution) or 1 (if execution failed)
Function getSubstring() arguments
char *source - Source string which will be read from the user and provided to the function as an argument
char *target - Target string, substring will be assigned in this variable
int from - Start index from where we will extract the substring (it should be greater than or equal to 0 and less than string length)
int to - End index, the last character of the substring (it should be less than string length)