STARTING OUT WITH C++FROM CONTROL STRU
STARTING OUT WITH C++FROM CONTROL STRU
18th Edition
ISBN: 9781323815458
Author: GADDIS
Publisher: PEARSON
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 10, Problem 37RQE

Explanation of Solution

Use of pointers to pass C-string argument:

In C++, for passing C-string argument the pointers are extremely useful. Each letter is passed through the pointer parameter variable. It will read until the null character, are part of the string.

Example program:

Consider the example that defines a function that uses a pointer to count the number of times a particular letter appears in a C-string is as follows:

//Header files

#include<iostream>

using namespace std;

//function prototype

int count(char*, char c);

// Define Main function

int main()

{

//Declare the constant variable

const int S = 20;

// Declare the variables as char type

char str[S], l;

//Get the input string from the user

cout << "Enter the string: ";

cin.getline(str, S);

//Get the letter from the user

cout << "Enter a letter: ";

cin >> l;

//call the function

cout << "The total number of times the " << ...

Blurred answer
Students have asked these similar questions
8.10 (Appending Part of a String) Write a program that uses function strncat to append part of a string to another string. The program should input the strings, and the number of characters to be appended, then display the first string and its length after the second string was appended. **Note solve question without using pointers in c language
In c++ create a program that will take user input of integers via the console. Enter a negative value to end the input. Create a histogram that outputs the date. use VECTORS not arrays. The histogram will be outputted using bins with each bin being of size ten. Example Bin 1 is from 0-9 Bin 2 10-29 etc...... Output the histogram to the console.
Write in C Language Description Please finish the following function char *replace(charsource, char constpattern, char constreplacement) A sequence of calls to this function replace the pattern with replacement. On a first call, the function expects a C string as argument for source, and this function scan for source to find the first pattern appear in source than replace it with replacement. In subsequent calls, the function expects a null pointer and uses the position right after the end of the last replacement as the new starting location for scanning. This function return source. Please see following example. char source[100] = "1223456789", pattern[10] = "2", replacement[10] = "123"; printf("%s", replace(source, pattern, replacement)); //Here should print out 112323456789 printf("%s", replace(source, pattern, replacement)); //Here should print out 11123323456789 printf("%s", replace(NULL, pattern, replacement)); //Here should print out 1112331233456789   function char…

Chapter 10 Solutions

STARTING OUT WITH C++FROM CONTROL STRU

Ch. 10.5 - Write a short description of each of the following...Ch. 10.5 - Write a statement that will convert the string 10...Ch. 10.5 - Prob. 10.13CPCh. 10.5 - Write a statement that will convert the string...Ch. 10.5 - Write a statement that will convert the integer...Ch. 10.6 - Prob. 10.16CPCh. 10 - Prob. 1RQECh. 10 - Prob. 2RQECh. 10 - Prob. 3RQECh. 10 - Prob. 4RQECh. 10 - Prob. 5RQECh. 10 - Prob. 6RQECh. 10 - Prob. 7RQECh. 10 - Prob. 8RQECh. 10 - Prob. 9RQECh. 10 - Prob. 10RQECh. 10 - The __________ function returns true if the...Ch. 10 - Prob. 12RQECh. 10 - Prob. 13RQECh. 10 - The __________ function returns the lowercase...Ch. 10 - The _________ file must be included in a program...Ch. 10 - Prob. 16RQECh. 10 - Prob. 17RQECh. 10 - Prob. 18RQECh. 10 - Prob. 19RQECh. 10 - Prob. 20RQECh. 10 - Prob. 21RQECh. 10 - Prob. 22RQECh. 10 - Prob. 23RQECh. 10 - Prob. 24RQECh. 10 - The ________ function returns the value of a...Ch. 10 - Prob. 26RQECh. 10 - The following if statement determines whether...Ch. 10 - Assume input is a char array holding a C-string....Ch. 10 - Look at the following array definition: char...Ch. 10 - Prob. 30RQECh. 10 - Write a function that accepts a pointer to a...Ch. 10 - Prob. 32RQECh. 10 - Prob. 33RQECh. 10 - T F If touppers argument is already uppercase, it...Ch. 10 - T F If tolowers argument is already lowercase, it...Ch. 10 - T F The strlen function returns the size of the...Ch. 10 - Prob. 37RQECh. 10 - T F C-string-handling functions accept as...Ch. 10 - T F The strcat function checks to make sure the...Ch. 10 - Prob. 40RQECh. 10 - T F The strcpy function performs no bounds...Ch. 10 - T F There is no difference between 847 and 847.Ch. 10 - Prob. 43RQECh. 10 - char numeric[5]; int x = 123; numeri c = atoi(x);Ch. 10 - char string1[] = "Billy"; char string2[] = " Bob...Ch. 10 - Prob. 46RQECh. 10 - Prob. 1PCCh. 10 - Prob. 2PCCh. 10 - Prob. 3PCCh. 10 - Average Number of Letters Modify the program you...Ch. 10 - Prob. 5PCCh. 10 - Prob. 6PCCh. 10 - Name Arranger Write a program that asks for the...Ch. 10 - Prob. 8PCCh. 10 - Prob. 9PCCh. 10 - Prob. 10PCCh. 10 - Prob. 11PCCh. 10 - Password Verifier Imagine you are developing a...Ch. 10 - Prob. 13PCCh. 10 - Word Separator Write a program that accepts as...Ch. 10 - Character Analysis If you have downloaded this...Ch. 10 - Prob. 16PCCh. 10 - Prob. 17PCCh. 10 - Prob. 18PCCh. 10 - Check Writer Write a program that displays a...
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
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning