Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 4PP

Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed. Write a main program to test your function on various strings of both even and odd length.

Blurred answer
Students have asked these similar questions
Write a python function which will take 2 arguments. They are: Sentence position Your first task is to take these arguments as user input and pass these values to the function parameters. Your second task is to implement the function and remove the characters at the index number which is divisible by the position (Avoid the index number 0 as it will always be divisible by the position, so no need to remove the index 0 character). Finally, add the removed characters at the end of the new string. Return the value and then finally, print the new string at the function call. ===================================================== Input:"I love programming."3Function call:function_name("I love programming.", 3)Output:I lveprgrmmngo oai. ============================================== Input:"Python is easy to learn. I love python."6Function call:function_name("Python is easy to learn. I love python.", 6)Output:Pythonis eay to earn.I lov pythn. sl eo
This question has three parts a. Write a C function called stringCopy(destination, source). This function takes two C strings as parameters and copies the source string into the destination string. Once the copy is completed, the function returns the number of characters (except null) that were copied. You cannot use the C library functions strcpy, strcat or any of their variants. You need to write all the code required to do the copy yourself. However, you may use a C library function to determine the length of a string.    b. What is the important precondition for stringCopy to work? Explain why the precondition is necessary.  c. Write a C main program to demonstrate/test that your stringCopy function works. You will need the program to read user input into the source string.
Write and test a function that removes the leading and trailing spaces from a string. The function has two parameters. The first parameter is the address of the original string. The second parameter is the address of a string that is almost a copy of the original string. The difference between the strings is that the first string may have leading or trailing spaces and the second string will not have leading or trailing spaces. Use the function Str_length to compute the length of the original string

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License