title: Sum of Digits in a String (using string objects) C++
body: <p>I am currently trying to take a user input string of digits, convert them individually into an int, and total their sum. </p>
  
  <p>EX: If user enters "1234", program should do 1 + 2 + 3 + 4 and display "10". I have tried experimenting a lot but seem to be at a stand still.</p>
  
  <p>I'm looking to create this code using C-string/String objects, and with "istringstream()" if possible (not necessary though...[esp if there are easier ways...])</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  using namespace std;
  
  int main()
  {
      string digits;
      int total = 0, num;
  
      cout &lt;&lt; "Enter a string of digits, and something magical will happen to them..." &lt;&lt; endl;
      cin &gt;&gt; digits;
  
      for (int i = 0; i &lt; digits.length(); i++)
      {   
          cout &lt;&lt; digits.at(i) &lt;&lt; endl;
          istringstream(digits.at(i)) &gt;&gt; num;
          cout &lt;&lt; num &lt;&lt; endl;    // Displays what came out of function
          total += num;
      }
  
      cout &lt;&lt; "Total: " &lt;&lt; total &lt;&lt; endl;
  
      // Digitize me cap'm
      // Add string of digits together
      // Display Sum
      // Display high/low int in string
  }
  </code></pre>
  
  <p>What am I doing wrong? Why do I keep getting super high numbers in the for loop? Are there more efficient functions I should be using? Thank you for any help :)</p>