You don't need to pass the length of foo into the function (your size parameter), as you know, the string object has the length member function that returns its own length. Just pass the string itself into the function and use the length member function where necessary.

Aside from the comment already given above, nothing in case 1 does anything to create a "1" or "0" return string as you require.

Some suggestions...

Checking for a given character in a string (use the find member function):
Code:
string test("varname = varvalue");
string::size_type index = test.find('=');
if( index != string::npos )
{
    // We found an = character at position given by index
}
else
{
    // No = character found
}
Getting the before and after strings (use the above index result and combine that with the substr function):
Code:
string before = test.substr(0,index);
string after = test.substr(index+1);