A runtime error of finding all permutations of a string
This is a programming problem. 

I need to get all permutations of a string and return them to a vector. 

But, I got error: 

 terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::erase
Aborted

In gdb: 

File "/usr/share/gdb/python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Error reading string from inferior: Input/output error
) at permStr.cpp:20
20                      ss.erase(i, 1) ;


--------------- my code ----------------
    
      vector<string> perm(string s)
     {
        vector<string> v;
        if (s.empty())
                return v;
        string ss(s);

        vector<string> v1;
        int size  = ss.size();
        for (int i = 0; i < size ; ++i)
        {
                ss.erase(i, 1) ;
                v = perm( ss ) ;
                vector<string>::iterator itr;
                for (itr = v.begin(); itr != v.end(); ++itr)
                {
                        v1.push_back(s[i]+ *itr);

                }
        }
        return v1;

      }


    int main()
    {
        string a("abc");
        vector<string> d;
        vector<string>::iterator itr;
        d = perm(a);
        for (itr = d.begin() ; itr != d.end(); ++itr)
        {
                cout << *itr << endl ;
        }
        return 0;
    }

Any help will be appreciated. 

A runtime error of finding all permutations of a string
===

This is a programming problem. 

I need to get all permutations of a string and return them to a vector. 

But, I got error: 

 terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::erase
Aborted

In gdb: 

File "/usr/share/gdb/python/libstdcxx/v6/printers.py", line 469, in to_string
    return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
RuntimeError: Error reading string from inferior: Input/output error
) at permStr.cpp:20
20                      ss.erase(i, 1) ;


--------------- my code ----------------
    
      vector<string> perm(string s)
     {
        vector<string> v;
        if (s.empty())
                return v;
        string ss(s);

        vector<string> v1;
        int size  = ss.size();
        for (int i = 0; i < size ; ++i)
        {
                ss.erase(i, 1) ;
                v = perm( ss ) ;
                vector<string>::iterator itr;
                for (itr = v.begin(); itr != v.end(); ++itr)
                {
                        v1.push_back(s[i]+ *itr);

                }
        }
        return v1;

      }


    int main()
    {
        string a("abc");
        vector<string> d;
        vector<string>::iterator itr;
        d = perm(a);
        for (itr = d.begin() ; itr != d.end(); ++itr)
        {
                cout << *itr << endl ;
        }
        return 0;
    }

Any help will be appreciated. 
