Don't know what you exactly want, anyway this is the official syntax:
#include <string>
void resize( size_type num, const TYPE& val = TYPE() );
So, you cannot just add 1 in the resize syntax, as you did here:
str.resize((str.size)+1);
Instead, try something like this:
Code:
int newsize = str.size() + ;1
str.resize(newsize);
Here's an example:
Code:
#include <string.h>
#include <iostream.h>
using namespace std;
int main ()
{
string some_string;
int new_string_size;
cout << "Enter a string:\n";
cin >> some_string;
cout << "string size = " << some_string.size () << endl << endl;
if (some_string.size () % 2 == 0)
{
cout << "Your string size is even.\n";
} else
{
new_string_size = some_string.size () + 1;
some_string.resize (new_string_size);
cout << "Your string size was odd and has now been made even.\n\n";
}
}