Please embedded the solution into program so that it compiles. Thank you, #include //To do user inputs and outputs #include //To use vectors #include //To use special string functions #include //To use back_inserter   using namespace std;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Need help fixing C++ program. Please help me convert a string vector unto a character vector.

Please embedded the solution into program so that it compiles. Thank you,

#include <iostream> //To do user inputs and outputs

#include <vector> //To use vectors

#include <string> //To use special string functions

#include <iterator> //To use back_inserter

 

using namespace std;

 

template <class T>

void output(vector<T> values) //Function needed to print vector

{

for (int index = 0; index < values.size(); ++index) //Cycle through entire vector # of elements found

{

cout << values[index] << " "; //Print value

}

cout << endl;

}

 

template <class T> void

rotateLeft(vector<T>& values)

{

for (int index = 0; index < values.size(); ++index) //Cycle through entire vector # of elements found

{

output(values); //Print vector to user

T tempValue = values[0]; //Start vector from the beggining

for (int move = 0; move < values.size() - 1; ++move) //Cycle through entire vector element to be modified

{

values[move] = values[move + 1]; //Move value ahead once

}

values[values.size() - 1] = tempValue; //Store the value of the modified location

}

}

 

bool validateInputDigits(string input) //Validate if input is numeric or string

{

for (int i = 0; i < input.length(); i++) //Check through each character in the input

{

if (isalpha(input[i]) == false && (input[i] != '.')) //Check for alphabetical values

{

cout << "\nUser did not enter the a alphabetical character. Please re-start program.\n";

exit(0);

}

}

return true;

}

 

int main()

{

vector<char> charVectorInput = {}; //Vector for user entered characters

 

const int SIZE = 4; //Size of user entered input vectors

vector<string>input(SIZE); //Vector to check all user inputs

 

//Section for character inputs

cout << "\nEnter four character values.\n"; //Accept 4 user entered values

for (int index = 0; index < SIZE; index++)

{

cout << "Please enter input # " << (index + 1) << ": ";

cin >> input[index]; //Accept input from user

validateInputDigits(input[index]); //Check if input is string or numeric

//*****Need help here. I can not copy a string vector to a character vector.

//I need to convert from string data type to char data type,

//and keep it as a vector to meet the assingment requirements

charVectorInput.push_back(input[index]); //Convert and assing value

}

cout << endl;

rotateLeft(charVectorInput);

cout << endl;

 

return 0;

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY