title: How to add integers and strings in the same vector?
body: <p>I need help for my university homework. i'm still new to this.</p>
  
  <p>Basically i am doing a run-length encoding and i don't know how to add the letter after the counter:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;stdexcept&gt;
  
  void error(std::string str)
  {
      throw std::runtime_error(str);
  }
  
  int main()
  {       int counter = 1;
          std::string id;
          std::vector&lt;int&gt; v;
          std::cout &lt;&lt; "Enter the data to be compressed: ";
          std::cin &gt;&gt; id;
  
          try
          {   for(int i = 0; i &lt; id.size(); i++)
              {
                  if(std::isdigit(id[i]))
                     error("invalid input");
              }
  
              std::cout &lt;&lt; "The compressed data is: ";
              for(int i = 0; i &lt; id.size(); i++)
              {
                  if(id[i] == id[i+1])
                 {
                     counter++;
                 }
                 else if(id[i]!= id[i+1])
                 {
                     v.push_back(counter);
                     v.push_back(id[i]);
                     counter=1;
                 }
              }
              for(int j = 0; j &lt; v.size(); j++)
                  std::cout &lt;&lt; v[j];
          }
          catch(std::runtime_error&amp; str)
          {
              std::cerr &lt;&lt; "error: " &lt;&lt; str.what() &lt;&lt; std::endl;
              return 1;
          }
  
   return 0;
  }
  </code></pre>
  
  <p>For example if i input aaabbb, the probram should output 3a3b. The problem is that it outputs 397398 97 and 98 being the ascii code for a and b.
  i don't know how to put the letter after the counter and for them to be in the same vector.</p>