Only use sizeof() for locally allocated buffers.
Always use strlen() for variables passed from outside.
Why: using sizeof() with a pointer to char passed to you will return
the size of the pointer itself (which is 4 always) not the size of the
allocated space to that buffer.
Always use strlen() for variables passed from outside.
Why: using sizeof() with a pointer to char passed to you will return
the size of the pointer itself (which is 4 always) not the size of the
allocated space to that buffer.
1 comment:
nice tip
Post a Comment