On March 26, 2005 07:41 pm, Mrs. Brisby wrote:
> On Sat, 2005-03-26 at 15:15 -0600, Eric Bohlman wrote:
> >      #define SEX "'M'"
> >
> > >    sqlite3_bind_text(stmt, index, SEX, sizeof(SEX), SQLITE_TRANSIENT);
>
> [note the extra ' in SEX]
>
> > Change sizeof to strlen here (and in the corresponding statement below);
> > sqlite3_bind_text wants the length of the string, not the size of the
> > pointer to it.
>
> sizeof(SEX)-1 is fine.

I hope you mean strlen(SEX)-1

sizeof is a compile time macro like operator, it returns the size of the thing 
you pass, be it a normal variable or a pointer, and since literal strings 
evaluate to a pointer, you'll get sizeof(char *), or 4 on x86.

-- 
Thomas Fjellstrom
[EMAIL PROTECTED]

Reply via email to