Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A6E3 (6 points-C Program Exclude any existing source code files that may already be in your IDE project and add two naming them C1A6E3-GeSubstring.c and

image text in transcribed
A6E3 (6 points-C Program Exclude any existing source code files that may already be in your IDE project and add two naming them C1A6E3-GeSubstring.c and ciAE3 main.c Do no these files in each other or in any other file. However, you may use it to file(s) you need new ones t use #include to include either of include any appropriate header File C1A6E3 a new string of characters by copying them fro etSubstring.c must contain a function named GetSubstring whose purpose is to create m an existing string. Its syntax (prototype) is char * Getsubstring(const char source[], int start, int count, char result[]); where source represents the string from which to copy the characters, start is the index in source of the first character to copy. count is the number of characters to copy. and result represents an array into which the characters are to be copied. For example, if the string in source is investments, the start index is 2, and the character count is 4, the characters vest will be copied from source into result and a '1e' will be appended Function GetSubstring must 1. handle the following three situations: a. If start is within the string in source and count does not extend beyond the end of it- b. If start is within the string in source but count does extend beyond the end of it- c. If start is beyond the end of the string in source- Copy count characters into the result array and append ae Copy all characters remaining in source into the result array and append a 1 Store only a 1e' in the result arra 2. return a pointer to the first element of the result array 3. use only one variable other than formal parameters source, start, count. and result; i must be an automatic variable of type "pointer to char not call any functions, use any macros, or display anything not use the sizeof operator (it wouldn't help anyway): not use index or pointer offset expre moving pointer expressions like *pointer++ and pointer++ are more appropriate. If you have trouble with this it may help to write the program using index notation first, then convert to compact or moving pointers 4. 5. 6. like pointer[i] and *(pointer +i). Compact or File CIA6E3 main.c must contain function main, which: 1. prompts the user to enter a sequence of 0 or more arbitrary printable characters (which may 2. prompts the user again to enter a space-separated start index and character count on the 3. calls GetSubstring(source, start, count, result). where result is a 256-element include spaces) then stores them as a string in a 256-element character array named source same line then stores them in type int variables named start and count, respectively: character array, and displays the results of the extraction in the following format, where the quotes, commas, and the literal word extracts are all required. This output is for the example provided in the description of the GetSubstring function above "investments", 2, 4, extracts "vest" The pointer returned by Getsubstring not the result array itself must be used to display the Test your program several times, using at least the 7 user entry sets shown on the next page

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions