Write a program to find the substring in c

Write a program to find the substring in c. Use the C substring program to find a substring of a string and all of its substrings. A string that is a substring of another string is referred to as a substring. Substrings of the string “the” include, for example, “h,” “he,” and “e.” In the header file “string.h,” there is no library function for finding a substring directly.

#include <stdio.h>
int main()
char string[1000], sub[1000];
int position, length, c = 0;
printf("Enter the element\n");
printf("Enter the position and length\n");
scanf("%d%d", &position, &length);
while (c < length) {
sub[c] = string[position+c-1];
sub[c] = '\0';
printf("Substring is \"%s\"\n", sub);
return 0;


Enter the element
c programming
Enter the position and length
Substring is ” “