You have to think about what data each layer provides. The variable str, a string, is an array of characters. A character is just an integer of one byte. That means the value of str[j] is an integer that could range from 0 to 255, the range of one byte. That value is used to index into the hash_pat and hash_str arrays which are 256 elements in length.
It might be more clear for you if you expand the expression like this :
for( int i = 0; i < len2; ++i )
{
int index = pat[i];
++hash_pat[index];
}
That just takes the inner expression and saves it to a temporary variable called index but the same things are happening in this.
FWIW, if this was my code I would be using temporary variables much more. For one thing, I think it makes things easier to see in the debugger. Here's an example :
for (int j = 0; j < len1 ; j++)
{
int tempstrj = str[j];
hash_str[tempstrj]++;
if (hash_pat[tempstrj] != 0 &&
hash_str[tempstrj] <= hash_pat[tempstrj] )
count++;
if (count == len2)
{
int tempstrst = str[start];
while ( hash_str[tempstrst] > hash_pat[tempstrst]
|| hash_pat[tempstrst] == 0)
{
if (hash_str[tempstrst] > hash_pat[tempstrst])
hash_str[tempstrst]--;
start++;
}
int len_window = j - start + 1;
if (min_len > len_window)
{
min_len = len_window;
start_index = start;
}
}
}