Hello,
I am working on small program that reads in a string consisting of minimum two words and a space between them. My dilemma is that i keep getting an error message. Can anyone twlm me what it is that i a ding wrong?
here is my code:
#include <iostream>
#include <string>
using namespace std;
// Prtototype
void stringmod(string, string&, string&);
int main()
{
string string_in;
string string1;
string string2;
cout << "Please enter the string with spaces: " << endl;
cin >> string_in;
stringmod(string_in, string1, string2);
cout << string1 << string2;
return 0;
}
// Function Definition
void stringmod( string string_in, string& string1, string& string2)
{
string positionSpace, length;
positionSpace = string_in.find (' ');
string1 = string_in.substr(0,positionSpace);
string2 = string_in.substr(positionSpace,string_in.length()-1);
}