[ad_1]
I don’t understand why you are using std::vector. You could calculate the sum without using the vector:
int k=0,sum=0;
for(int i=0;i<s.length();i++)
{
k = s[i]-'0';
sum += k;
}
Note: if you are a little paranoid of the sum value fitting into an integer, you can use an unsigned integer since digits can’t be negative.
[ad_2]
solved OUTPUT ERROR,The problem is to find the sum 5000 digit number cpp [closed]