jewee
asked on
Appending strings onto a string
I am trying to do the following:
If there is a match, I need to append a string onto an existing one.
How is the implementation done using std strings?
std::string fscript;
for .....
{
//if match
add on a string and " " to end of existing string...
If there is a match, I need to append a string onto an existing one.
How is the implementation done using std strings?
std::string fscript;
for .....
{
//if match
add on a string and " " to end of existing string...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
maybe it's better to add space character first ...
std::string fscript, word;
while ( !end )
{
...
word = nextWord();
if ( match )
{
fscript += ' ';
fscript += word;
}
}
Note, you cannot not do it by one statement
fscript += (' ' + word); // compile error
as std::string has no operator + (..) but only operator += (..) .
Regards, Alex