Question: Why must getline() be used insteadof cin to get string input? Give an example of when you would need touse cin.ignore() in your code Strings

  1. Why must getline() be used insteadof cin to get string input?
    1. Give an example of when you would need touse cin.ignore() in your code
    2. Strings in C++ are mutable, this is different than in Javawhere strings were immutable. What do we mean by mutableversus immutable?
    3. Imagine your code had the following string variable init string message ="HH231JJ"; Write a for loop that uses the [ ]operator to change each 'H' character in the message string toa '#' character.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!