char alphabet[26];
for ( int i = 0; i < 26; ++i )
alphabet[i] = i + 'a';
I don't really understand it. i + 'a', so you make a sum (the integer + the letter 'a')? Why does this work and why do you get the alphabet letters as the result?
Characters are stored as integers in computers, every character has it's own numerical value.
For example 97 == 'a'
See http://www.asciitable.com/ for more.
As in the ASCII table the English alphabet's characters are in a continuous range, we can cheat like in your example. This is equivalent to yours : alphabet[i] = i + 97;
Also literals in double quote are "strings", and literals in single quote are 'c' characters, the latter represents a single numerical value, while the former is a 0 terminated array of numerical values.
This particular code uses a loop to store the lowercase alphabet into
char alphabet[26];
What you see happening on line 3 constant value of 'a' (based on the ASCII chart) which is 97 being added to the iterator. In C and C++, integers and characters are practically the same thing and can be used together like that...
alphabet[0] = 0 + 97; // The letter 'a'
alphabet[1] = 1 + 97; // The letter 'b'
alphabet[2] = 2 + 97; // The letter 'c'
alphabet[3] = 3 + 97; // The letter 'd'
// etc...
The result... an array of 26 bits with all the lowercase letters in it :)