Print All the subset

I want to print all the Ppower set of a string let say the string
INPUT - "ab"
OUTPUT - " ", "a", "b", "ab"

#include <bits/stdc++.h>
using namespace std;

void solve(string ip, string op)
{
    if (ip.length() == 0)
    {
        cout << op;
        return;
    }
    string op1 = op;
    string op2 = op;
    op2.push_back(ip[0]);
    ip.erase(ip.begin() + 0);
    solve(ip, op1);
    solve(ip, op2);
}

int main()
{
    string ip = "ab";
    string op = "";
    solve(ip, op);
    // cout << "Hello";

    return 0;
}

In this code only three subset of this string is coming "a", "b" and "ab" not " ". Dont know where my code is stuck.
Thank you

Comments (1)