Reading
sub_string.c
#include <stdio.h>
int main()
{
char string[1000], sub[1000];
int position, length, c = 0;
printf("Input a string\n");
gets(string);
printf("Enter the position and length of substring\n");
scanf("%d%d", &position, &length);
while (c < length) {
sub[c] = string[position+c-1];
c++;
}
sub[c] = '\0';
printf("Required substring is \"%s\"\n", sub);
return 0;
}
Output-
Input a string
c programming
Enter the position and length of substring
3
11
Required substring is "programming"
C Programming
C Programs
1 comments
Good
ReplyDeleteHere is blog for basic C and C++ programs
List of C and C++ Programs
blog link
C and C++ based programs