string countx(string sky)
    int count=0;
    for(int x=0;x<=sky.size();x++)


  stringstream ins;
  string bang; // Declare an input string stream.
cout<<"count  " <<count;

ins << count;
bang = ins.str();
   sky=sky+"x^"+ bang;
  cout<<"Sky == "<<sky<<"\n";
  return sky;

Writing a function that will take in a string as input and then searches number of "x" in it then it writes x^count.

I am not able to figure out what is wrong ??

I have put on many cout functions .

Example input is

"x x"

It should actually return

but returns "x^1"