-2

like when when s = "wendy", I got 551. What's that?

for(size_t i = 0; i < s.length(); i++)
{
    sum += s.at(i);
}
Yuan Wang
  • 369
  • 1
  • 3
  • 4

2 Answers2

2

It's the sum of the ascii values in the string. Each character corresponds to a numerical value usually between 32 and 127 (ignoring wide characters and Unicode stuff for now since that's complicated).

If you want more information, try looking up "Ascii".

Antimony
  • 37,781
  • 10
  • 100
  • 107
2

From an ascii table:

'w' = 119
'e' = 101
'n' = 110
'd' = 100
'y' = 121
---
551
typ1232
  • 5,535
  • 6
  • 35
  • 51