I\'m trying to learn c++ on my own and I\'ve hit a bit of a road block. The problem is I need to take an integer,split it into its digits and get the sum of the digits and
A simple solution:
int n = 12345; vector digits; while (n != 0) { digits.insert(digits.begin(), n%10); n /= 10; } for(auto & i : digits) cout << i << " ";
output: 1 2 3 4 5