The following is a program to extract substring from a given string. The substring will be chosen number of charachters strarting from the first character.
The user will be asked to enter a string, and then the number of characters that need to be extracted from it.
The user entered length should not be greater than the length of the original string, thus the string length and requested length are compared and the program stops if requested length is greater than the original string length.
The value of the original string starting from the first character, till the requested length is copied into the new substring. The substring is appended with a null character to indicate end of string.
The user will be asked to enter a string, and then the number of characters that need to be extracted from it.
The user entered length should not be greater than the length of the original string, thus the string length and requested length are compared and the program stops if requested length is greater than the original string length.
The value of the original string starting from the first character, till the requested length is copied into the new substring. The substring is appended with a null character to indicate end of string.
No comments:
Post a Comment