+ 8
std::string str = "test"; int sum = 0; for (char i : str) sum += int(i); std::cout << sum;
27th Sep 2017, 2:25 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
I dont know much about C++ but I guess this can be achieved by typecasting each character of a string into a char value and then into an int value.
27th Sep 2017, 2:17 PM
Mayur Garg
Mayur Garg - avatar