Write a function called s to extract a portion of a character string. The function should be called as follows:
s
where S is the character string from which you are extracting the substring, S is an index number into S indicating the first character of the S, c is the number of characters to be extracted from the S string, and r is an array of characters that is to contain the extracted substring.
For example, the call
s
extracts the substring̎ (three characters starting with character number 4) from the string̎ and places the result in r.
Be certain the function inserts a null character at the end of the substring in the result array. Also, have the function check that the requested number of characters does, in fact, exist m the string. If this is not the case, have the function end the substring when it reaches the end of the source string. So, for example, a call such as
s
should just place the string “words” inside the result array, even though 20 characters were requested by the call.
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Programming in C
Additional Engineering Textbook Solutions
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Starting Out with C++: Early Objects
Starting Out with Java: Early Objects (6th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting out with Visual C# (4th Edition)
Starting Out With Visual Basic (8th Edition)
- Define a function named reverse() that accepts an array of strings and display it in the reverse order. Example: Given the array: $a=array(“apple”,”orange”,”banana”,”kiwi”) The function must display: kiwi banana orange apple b. Create an array and call the function reverse() use phparrow_forwardWrite a function that displays an n-by-n matrix using the following header: void printMatrix(int n)Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix.arrow_forwardBinary to String To translate the binary data, convert the binary information into ASCII characters. Create the function binary_to_ascii_string() that accepts a list of binaries, binary_values, and returns them as a string. As an example, the list [‘01000001’, ‘01101100’, ‘01100101’, ‘01111000’] will return the string ‘Alex’ and the list [‘01100100’, ‘01110101, ‘01100100’, 01110101] will return the string ‘dudu’.arrow_forward
- Write a function calculate_expression(values) that calculates and returns the value of the following expression: ((angle - 34) ** (1./a)) / (vol ** b) The function receives as input a dictionary containing the values of the parameters (a, b, vol, angle). The string name of the parameter is the key and the associated number is the value. The result must be rounded to three digits after the comma.arrow_forwardExercise Objectives Problem Description Write a program that reads a string and mirrors it around the middle character. Examples: abcd becomes cdab. abcde becomes deCab AhmadAlami becomes AlamiAhmad Page 1 of 2 Your program must: • Implement function void reflect (char* str) which receives a string (array of characters) and mirrors it. This function does not print anything. • Read from the user (in main()) a string and then print the string after calling function reflect(). • Use pointers and pointer arithmetic only. The use of array notation and/or functions from the string.h library is not allowed.arrow_forwardDefine the following functionarrow_forward
- C++ Write a program that first asks the user to enter a string and then asks the user to enter a character. The program should display the number of times the character appears in the string. Use the function Count_char(). A function Count_char() that has two arguments. The first argument is an array and the second argument is a character. The function returns an integer.arrow_forwardDefine a function that accepts a string as its input parameter and returns an array including the individual characters included in the input string. For example, if the function is called for "ABC", the function returns: ['A', 'B', 'C'] javascript, pleasearrow_forward1. Write a function called `CleanString` that takes one argument, an accounting number formatted as a string, and returns the number as a float. For example, if the argument is the string '$(7,074,619)', the return value should be the float -7074619. This function should be created in the first code cell below. 2. Iterate over the list `data` and "apply" the function `CleanString` to each element of the list. Save the result to a new list, `cleandata` (this iterating should be completed in the second code cell below).arrow_forward
- In C Languagearrow_forwardPython language Please don't use in loopsarrow_forwardComputer Science C++ Write a program that: Gets a character array (C-string) using cin.get to allow blanks in the C-string Prints the C-string (what they input) Prints the length (number of characters) in the C-stringarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning