Chapter - 10: Strings

Write a program that extracts part of the given string from the specified position. For example, if the string is "Working with strings is fun", then if from position 4, 4 characters are to be extracted then the program should return string as "king". Moreover, if the position from where the string is to be extracted is given and the number of characters to be extracted is 0 then the program should extract the entire string from the specified position.


D
Sections
3
Exercises
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
	char sen[100];
	int i;
	printf("Enter your sentence. (Less than 100 chracters)\n\n");
	gets_s(sen);
	printf("After how muany characters you want to extract the line : ");
	scanf("%d", &i);
	i--;
	if (i<0)
		i = 0;
	printf("%s\t", &sen[i]);
	_getch();
	return 0;
}

© 2021 Garbage Valuegarbage value logo