|
-
November 10th, 2007, 09:55 AM
#2
Re: strlen vs sizeof
sizeof() returns the size of the operand, not a string length - they are two different things. When you declared 'string[]' it's size was fixed at 8 no matter what you copy into it later. In fact, you are overwriting the bounds of 'string' by copying another string that required 10 bytes. That's a good way to guarantee a program execution error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|