[SOLVED] CMSC 216 Exercise 2 Text Manipulation

$25

File Name: CMSC_216_Exercise_2_Text_Manipulation.zip
File Size: 348.54 KB

SKU: [Solved] CMSC 216 Exercise2 Text Manipulation Category: Tag:
5/5 - (1 vote)
e2_text_manipulation

Message Body:For this exercise you will implement two functions that manipulate text. The prototypes for the functions canbe found in file text manipulation.h.1. int remove spaces(const char *source, char *result, int *num spaces removed);This function places a copy of the source string in the out parameter result where all leading and trailingspaces have been removed. If the out parameter num spaces removed is different than NULL, the function will set the integer associated with the parameter to the number of spaces removed. The functionwill return one of two values: FAILURE or SUCCESS (see file text manipulation.h).a. FAILURE if the source string is NULL or its length is 0. In this case the result string is not assigneda new value (it keeps its original value).b. SUCCESS if spaces can be removed or no spaces are present.2. int center(const char *source, int width, char *result);This function generates a new string into the result out parameter where the source input string hasbeen centered in a string with length specified by the width parameter. Center the string by adding (tothe left and right of the original string) a number of spaces that corresponds to (width source stringlength) / 2. Notice that the resulting centered string has a length that is less than width when (width source string length) is odd. For example, if we were to center dogs in a field with of 7, the resultingstring is dogs (1 space to the left, 1 space to the right). The function returns one of two values:SUCCESS or FAILURE (see file text manipulation.h).a. FAILURE if source is NULL, if source length is 0, or if the width is less than the source length.b. SUCCESS if item is centered.You should look at the public tests in order to understand the functionality associated with the functions youmust implement. For this exercise, you can assume the user will not provide a string containing only blankcharacters. In addition, if a string has multiple words, the spaces between those words must be preserved.4 Requirements1. Unlike other assignments for this course, you can work together with other classmates, but you mayNOT exchange any code.2. If you are having problems with your code, use the class debugging guide available at:13. Your grade is based on the results obtained from the submit server. It is your responsibility to verify thatyour program generates the expected results on the submit server.4. Your code must be written in the file text manipulation.c.5. Do not add a main function to the text manipulation.c file.6. To compile a public test, compile your text manipulation.c file along with a public test file. For example:gcc public01.c text manipulation.c7. One source of bugs is forgetting to add a null character to a string.8. All your C programs in this course should be written using the compiler gcc with the options defined at9. Your program should be written using good programming style as defined at10. You just need to implement the two functions described above. You may write additional functions ifyou want, but define them as static.11. Do not change the text manipulation.h file provided.12. You are encourage to define your own tests (similar to public01.c, public02.c, etc.).13. You can use the C string library (string.h).14. Do not use any functions from ctype.h.15. You can assume the result char array will be long enough to contain the string functions will create.16. Do not use dynamic memory allocation.17. The example ptr add sub overview.c reviews concepts associated with this exercise.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CMSC 216 Exercise 2 Text Manipulation
$25