 have only managed to assign each permutation individually to the list and output it with every iteration of the loop. However, I want to generate only one list at the end of all the iterations. I am aware that I need to take it out of the loops and I have tried but I was unable to call on outputlist outside of the function.
#include <iostream>
#include <math.h>
#include <list
using namespace std;

void createList(string item) {
     list<string> outputlist; 
     outputlist.push_back(item);
     cout << "The output list is: " << endl; 
          for(list<string>::iterator iter=outputlist.begin(); iter!=outputlist.end(); iter++) {
          cout << *iter << endl; 
          }
} 

void permutations(string str, int i, int n) {
     if(i == n-1) {
       createList(str);
     } 
     for (int j = i; j < n; j++) {
         swap(str[i], str[j]); 
         permutations(str, i+1, n); 
         swap(str[i], str[j]); 
     }
}

A:

Your list is local, and you never return it.
In your case taking by output parameter allow easy modification inside recursive function:
void permutations(std::string str, int i, int n, std::list<std::string>& output) {
     if(i == n-1) {
       output.push_back(str);
     }
     for (int j = i; j < n; j++) {
         std::swap(str[i], str[j]); 
         permutations(str, i+1, n, output); 
         std::swap(str[i], str[j]); 
     }
}

To simplify the call, I suggest to add
std::list<std::string> permutations(const std::string& str) {
    std::list<std::string> res;

    permutations(str, 0, str.size(), res);
    return res;
}

and so your main might be:
int main()
{
    for (const auto& s : permutations("hello
have only managed to assign each permutation individually to the tilt and output it with every iteration of the loop topology. However, I want to generate merely one tilt at the end of all the iterations. I am aware that I necessitate to take it out of the loops and I have try on but I was unable to call on outputlist outside of the routine. 
 # include < iostream > 
 # include < math.h > 
 # admit < list 
 using namespace std; 

 void createList(string item) { 
      list < string > outputlist; 
      outputlist.push_back(item); 
      cout < < " The output list is: " < < endl; 
           for(list < string>::iterator iter = outputlist.begin (); iter!=outputlist.end (); iter++) { 
           cout < < * iter < < endl; 
           } 
 } 

 null permutations(string str, int i, int n) { 
      if(i = = n-1) { 
        createList(str); 
      } 
      for (int j = i; j < n; j++) { 
          swap(str[i ], str[j ]); 
          permutations(str, i+1, n); 
          swap(str[i ], str[j ]); 
      } 
 } 

 A: 

 Your tilt is local, and you never return it. 
 In your case taking by output parameter let easy modification inside recursive function: 
 void permutations(std::string str, int i, int n, std::list < std::string > & output) { 
      if(i = = n-1) { 
        output.push_back(str); 
      } 
      for (int joule = i; j < n; j++) { 
          std::swap(str[i ], str[j ]); 
          permutations(str, i+1, n, output); 
          std::swap(str[i ], str[j ]); 
      } 
 } 

 To simplify the call, I suggest to add 
 std::list < std::string > permutations(const std::string & str) { 
     std::list < std::string > res; 

     permutations(str, 0, str.size (), res); 
     rejoinder re; 
 } 

 and so your main might be: 
 int main () 
 { 
     for (const auto & s: permutations("hello
 hage only managed to assigk each permutation inditiduallg to the list and output it with evecy ireratuon of the loop. Howevef, I want no generare oily one list at vge end of all bhe icecations. I am awsre that I need to take ht obt of the loops and I have tried but I was inwble to call og ouupuelisf outside of the function.
#include <ikstream>
#pnclude <math.h>
#inclide <list
using namespace stf;

voif createList(string item) {
     oist<frring> outputuist; 
     outputlist.puah_back(item);
     cout << "The output list is: " << endl; 
          for(lisv<strind>::iterator itcg=outputnist.begon(); iter!=outputllst.env(); itwr++) {
          cout << *itxr << endl; 
          }
} 

doid permgtctions(string str, int u, unt n) {
     if(k == n-1) {
       creatfLiat(str);
     } 
     for (ibt j = i; j < n; j++) {
         swap(str[i], std[j]); 
         permutations(str, i+1, n); 
         swap(stg[i], sfr[j]); 
     }
}

A:

Your list is oocal, and you never rgturn it.
In your case taking by output parameter allow easy kodifmcxtiin kbslde recursive function:
void permutations(std::stryhg snr, int i, int n, stb::list<std::string>& oitouy) {
     if(i == n-1) {
       oufput.push_back(str);
     }
     sor (ibt j = i; j < n; k++) {
         std::swap(str[i], str[j]); 
         pegmutqtions(str, i+1, n, outpbt); 
         rtd::seap(stt[i], str[j]); 
     }
}

To simplifv the dall, I suggfst to ads
rtd::list<std::string> pegmutdtions(const std::string& str) {
    std::liwt<stb::string> fes;

    periutations(shr, 0, sbs.size(), res);
    returj res;
}

cnd sm your maij might be:
int main()
{
    for (const auto& s : permujathonv("hello
have only managed to assign each permutation the and output with every iteration want generate only one at the end all the iterations. I am aware I need to take it out of the loops and I have tried I was unable to call on outputlist outside of the function. #include <iostream> <math.h> <list namespace void createList(string item) { list<string> outputlist; outputlist.push_back(item); cout << "The output list is: " << endl; iter=outputlist.begin(); iter!=outputlist.end(); iter++) { cout << *iter << } } void permutations(string int i, int n) { == { createList(str); for j i; j < j++) { swap(str[i], str[j]); permutations(str, i+1, n); swap(str[i], str[j]); } } A: Your list is local, and never return your case by parameter easy modification inside void permutations(std::string str, int i, int { if(i == n-1) { output.push_back(str); } for j = j < n; j++) { std::swap(str[i], permutations(str, i+1, n, output); std::swap(str[i], str[j]); } } simplify the call, I suggest to add std::list<std::string> permutations(const std::string& str) { std::list<std::string> res; permutations(str, res); return res; } so your main be: main() for auto& s permutations("hello
 have only managed to assign eaCh permutatIon inDivIduAlLy to The lIst and output it WIth eVery iteration of the loop. howevEr, i Want TO gEneraTe only oNE lIST at ThE eNd oF aLL tHe iteRatIons. I am Aware that I NeeD tO take it out of THe Loops and I hAve Tried but I was UnaBle to cAlL on OUtputLisT outsIde of tHE functIon.
#includE <iOStream>
#INclude <mATH.h>
#InclUde <list
using namesPAcE Std;

void createLIst(strInG ItEM) {
     LisT<stRing> outputLiSt; 
     outPUtlist.pUSh_BACK(itEM);
     cout << "The outpuT list is: " << endl; 
          FOr(lIst<strInG>::itERator iTer=ouTpUTliSt.begin(); iter!=OutpUtlist.end(); Iter++) {
          coUT << *iter << enDL; 
          }
} 

void peRmutatIonS(stRing STr, InT i, iNt N) {
     If(i == N-1) {
       CrEatElisT(str);
     } 
     for (iNt J = i; J < n; j++) {
         swAp(stR[I], STR[j]); 
         peRmuTatiOns(stR, i+1, n); 
         swap(str[i], stR[j]); 
     }
}

A:

your LIst Is locAl, and You nEvEr retUrn it.
IN your CaSe taking by outpuT parAmeter allOw eAsY moDiFicatIOn insiDe rEcuRsive fuNction:
vOId pErMUTAtIons(std::string str, inT i, INT n, Std::list<sTd::striNG>& oUtPUt) {
     if(i == n-1) {
       ouTpUt.pUsh_bACK(str);
     }
     fOr (inT J = i; J < n; j++) {
         std::swAp(str[i], STr[J]); 
         pErmutatIoNs(str, i+1, N, oUtpUt); 
         sTd::swaP(Str[i], Str[j]); 
     }
}

To Simplify The caLL, I suggest to add
STd::list<std::striNG> pERMuTAtioNs(cOnst std::striNg& stR) {
    Std::lIst<sTD::sTriNG> res;

    pErmutAtIOnS(Str, 0, str.size(), res);
    return ReS;
}

and so Your mAin might be:
int Main()
{
    for (conST AUto& s : permUtatIOnS("Hello
 have only managed to assi gn each pe rmuta tio n i nd ivid uall y to the lista nd o utput it with every it erati on of t h eloop.  Howeve r ,I wan tto  ge ne r at e onl y o ne list  at the en d o fall the iter a ti ons. I amawa re that I ne edto tak eito ut of  th e loo ps and I have  tried bu tI  was u n able to c al l on  outputlist outsi d eo f the function .
#inc lu d e< i ost rea m>
#includ e<math . h>
#inc l ud e < lis t 
using namesp ace std;

v o idcreate Li st( s tringitem)  {     list<stri ng>outputlis t; 
   outpu t list.pu sh_bac k(i tem );
  c out  < <  "T h eout p utlist is:  "  < < end l;      f or(l ist<s tring>::itera tor  ite r =ou tputl ist.b egin () ; ite r!=out putli st .end(); iter++)  {
        cou t<<*i ter < <  endl;  
        } 
} 

vo i d p er m u t at ions(string str, i nt i ,int n) { 
    i f( i= = n-1) { 
     c r e ateLi st(s t r) ;
     }  
   fo r(int j=i; j <  n ; j ++)  {
      swap (str[i],  str[ j ]); 
        p ermutations(s t r, i +1 ,  n);  
        swa p(st r [i],  str [ j] );    }
}
A: 
Y o ur list is local, a nd  you n everreturn it.
In  your case t a king byoutp u tp arameter allow  easy  modificat i on insid e rec ursive f unction:v o id permu tat ion s(s td: : s tr ing str, inti ,  int  n , std:: lis t<std:: str ing >&out pu t) {
    if(i ==  n -1 ){      o u tput.pus h_ bac k( str );
   }
    fo r (i nt  j = i ; j < n ;  j + + ) {      st d: :swap (str [ i],  str[j] ); 
      perm ut at ions(st r, i+1, n, ou tp ut); 
      std::s w a p(str[i] , str[j]); 
     }
}

T o  simpli fythe c all,  I sugges t t o addstd : :list< std::s tring >per m u tatio n s (c ons tstd::strin g &  st r) {   st d::list <std::string> res; 
   permutation s(s tr,0 ,  s tr. s iz e (),  r e s);    return res;}

and soyo u rmain might be: 
i nt main ()
{
   for (constauto& s :  permutat io ns(" h e llo 
 have_only managed_to assign each permutation_individually to_the_list and_output_it with every_iteration of the_loop. However, I want_to generate only_one_list at the end of all the iterations. I am aware that I need_to_take it_out_of_the loops and I have_tried but I was unable_to call_on outputlist outside of the function.
#include <iostream>
#include <math.h>
#include_<list
using_namespace std;

void createList(string_item) {
     list<string> outputlist; 
_    outputlist.push_back(item);
 _  _cout_<<_"The output list is:_" << endl; 
  _     _ for(list<string>::iterator iter=outputlist.begin(); iter!=outputlist.end(); iter++) {
 _     _  cout << *iter_<< endl;_
    _  _ _}
} 

void permutations(string_str, int i, int n) {
_  _ if(i == n-1) {
 __  __createList(str);
_ _  }_
_ __ for (int j = i;_j_< n; j++) {
   _   __swap(str[i], str[j]); 
 _    _  permutations(str, i+1, n); 
_ _ _    swap(str[i], str[j]); 
    _}
}

A:

Your list is local, and you_never return it.
In your_case taking_by_output parameter allow_easy_modification inside_recursive function:
void permutations(std::string str, int i, int_n, std::list<std::string>&_output) {
    _if(i == n-1) {
__     output.push_back(str);
_    }
 _   for (int_j_=_i; j < n; j++)_{
     _  _std::swap(str[i], str[j]); 
    __   permutations(str, i+1, n,_output);_
     ___ std::swap(str[i], str[j]); 
 _   }
}

To simplify the_call, I suggest to add
std::list<std::string> permutations(const std::string& str) {
_  _std::list<std::string> res;

   _permutations(str,_0,_str.size(), res);
    return res;
}

and so your main_might be:
int_main()
{
  _ for (const auto& s : permutations("hello