
Caleb P. answered 02/14/22
Software Programmer and Game Developer
Hello Brock, here is a good snippet of code to get you started with C++ strings. The std::string namespace has a substr(from, to) function that is very useful for string manipulation:
// TrimString.cpp : This file contains the 'main' function. Program execution begins and ends there.
// ---------------
#include <iostream>
#include <string>
using namespace std;
string stringTrim(string word)
{
// Insert extra logic here to ensure word length > 2
string str = word.substr(1, word.length() - 2);
return str;
}
int main()
{
// Sub cin >> to get varied user input
string word = "chello";
string trimmed = stringTrim(word);
cout << trimmed << endl;
}
Dat K.
you cannot modify anything in the int main ()05/02/22