This post is about a program which accepts a string, index and postion and perfors triming. We can say it as a substring program. The index will determine the starting point and the position will determine the end point. This program replicats the substring() which is predefined in java. The bellow code is the c version of the substring function of the String class in java !
void substring(int a,int b)
printf("Enter THe String: ");
printf("Enter the value of limit A: ");
printf("Enter the value of limit B: ");
printf("The Value of fs is %s and the value of substring is %s",fs,ss);
When the string is fetched from the user, along with the index and position values, they are all passed to the substring(). Inside the substring() another variable ss is dynamically allocated according to the space required and so the trimmed string is stored in it. This code snippet can be used in your parent program.
Got bugs, report them !
Latest posts by Bikash Panda (see all)
- Firmata protocol with Raspberry Pi and Arduino - September 13, 2017
- IOT:Power outlet controlled from internet using WeMOS - August 9, 2017
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017