Q:

Warning when using sizeof for array subscript

Today I decided to compile my code with gcc -W -Wall and it's giving me a warning I just can't solve.
I was trying to reduce the amount of #defines i've been using, and thought sizeof() would be the answer. Everything else seems to be okay, only this one warning, but it's got me quite foxed:
if (1)    // set random id string for this session
    {
    register unsigned int count, until=sizeof(session.id);
    for (count=0;count<until;count++)
        {   session.id[count]=randchar();   }
    session.id[count]=0;
    }

The compiler is giving me this warning:
warning: array subscript is above array bounds

Can anyone tell me what's wrong with this?

A:

your error because of this :
session.id[count]=0;

change to this :
session.id[count - 1]=0;

