I am curious how this works to produce the provided output. The output is 4 which is the 5th character in the alphabet (which is expected) and subsequent alphabetical characters work all the way to the z character which also returns 25.
Example program
#include <iostream> #include <string> using namespace std; int main() { string str = "e"; int numericalvalue = ((str[0]) - 'a'); //this line of code im trying to understand cout << numericalvalue; return 0; }