Problem Solving with C++, Student Value Edition
10th Edition
ISBN: 9780134543680
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8.1, Problem 4STE
Suppose the function strlen (which returns the length of its string argument) was not already defined for you. Give a function definition for strlen. Note that strlen has only one argument, which is a C string. Do not add additional arguments; they are not needed.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a c++ function that takes a string as parameter and returns the number of words in that string.
Write a function that replaces a substring with a new string.
Example:
>>> replace('The quick brown fox jumps over the lazy dog', 'quick', 'slow')
The slow brown fox jumps over the lazy dog
The first parameter is the string, second is the substring to be replaced and the third is the string to replace the substring.
If there are more than one occurrence of a substring, replace it all.
solve this question by c programming
Write a function void printASCII() that takes a string as its parameter and prints the ASCIIvalue of each character in the string.
Chapter 8 Solutions
Problem Solving with C++, Student Value Edition
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
Knowledge Booster
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
- Write a function in C++ to take a string as parameter and also returns a string that is the palindrome of the given string. string createPalin(string s){ //Write your code here //Return a string that is palindrome of s }arrow_forwardWrite a C++ function named getLowerAlphabets that takes a C-string argument and returns a C-stringmade up of the lower alphabet characters of the argument. If none of the characters of the argument is alower alphabet then you must still return a C-string which is obviously empty C-string; that is a C-stringwith only the null character.arrow_forwardWrite a function in C progarmming language that gets a string str, changes all lower case letters to * (asterisk), and all upper case letters to $ (dollar sign). All other characters remain unchanged. The function returns the total number of letters modified. int hide_letters(char* str); For example: - If str is "12ab0", then the function changes it to "12**0", and returns 2. - If str is "aBCDe*", then the function changes it to "*$$$**", and returns 5. - If str is "0123&***", then the function keeps the string as is, and returns 0. - An empty string is also a string.arrow_forward
- Write a function in C++ that takes a string as a parameter and returns the sum of ASCII value of all lowercase alphabets in the string. The function returns 0 if no lowercase alphabet it is present in the string. Test the function taking a sample string inside the main function.arrow_forward(C++) Question: Write a function string middle(string str)that returns a string containing the middle character in str if the length of str is odd, or the two middle characters if the length is even. For example, middle("middle") returns "dd". I'm not getting the correct output. What am I doing incorrectly?arrow_forwardWrite a function hasBothCases that takes a a c-string and determines if it contains both the upper and lowercase forms of a letter, returning 11 if both the upper and lowercase form of a letter are part of the string and returning 00 if no such letter exists. For example, hasBothCases should return 11 for the strings "Nine", "Lowell", and "o_O", but should return 00 for "nine", "Massachusetts", and "zyBooks". HINTS: You can make use of either the following: (1) Assume that the <ctype.h> library has already been #included. 2) Upper case letter A starts at 65 and Upper case Z is 90 in ASCII code, while lower case a starts at 97 and z is 122. NOTE: You only need to write the function. In C programmingarrow_forward
- Write a C++ function named louder which accepts a pointer to a C-string as its argument. It should do 3 things: - change any period (.) in the C-string to an exclamation point (!) - change any lower case letter in the C-string to the corresponding upper case letter - return the number of characters which were changed You may assume that parameter str points to a valid, null-terminated C-string containing only alphabetic characters, spaces and periods. You do not need to demonstrate calling this function. Example: if str points to an array containing "Giants win." the function should change the array so that it contains "GIANTS WIN!", and should return 9. You must use this function signature: int louder(char *str)arrow_forwardWrite code for a C++ function that takes input a string and returns it's length without using any library function. Do fast please.arrow_forwardDo Programming Exercise 4 from Chapter 5 using a function acronym(phrase)that returns an acronym for a phrase supplied as a string.arrow_forward
- In C language, implement the function that gets a string str, changes all digits of str to 0 (zero), and returns the number of digits in the string. int digits_to_zero (char* str); For example: If str is "12ab0", then the function should change it to "00ab0", and return 3. If str is "abcde", then the function should keep it as is, and return 0. [Hint 1: you can check if a char is a digit using its numerical value. The numerical values of the digits are consecutive. For example, we have '3' + 2 =='5'] [Hint 2: you can also use the function isdigit (char c) implemented in the library <ctype.h> https://www.programiz.com/c-programming/library-function/ctype.h/isdigit]arrow_forwardWrite a function str_replace that takes three strings, str1, str2 and str3; and replaces the first occurence (if any) of str2 in str1 with str3, and returns the newly formed string. For example, str_replace("Nuclear Energy Engineering", "Nuclear Energy", "Mechanical") returns "Mechanical Engineering"arrow_forwardWrite a program in C to find vowels in a string s1 and concatente those vowels with string s2 in uppercase only. Take the input for s1 and s2 from user with the help of function only.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Algebraic Expressions – Algebra Basics; Author: TabletClass Math;https://www.youtube.com/watch?v=U-7nq7OG18s;License: Standard YouTube License, CC-BY
Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions; Author: ProgrammingKnowledge;https://www.youtube.com/watch?v=Os4gZUI1ZlM;License: Standard Youtube License