Results 1 to 2 of 2

Thread: Clearing an array of characters

  1. #1

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    char buf[90];
    memset(buf, 0, 90);
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Remember that if you want to just make a string empty, you don't have to zero out all the characters, but only the first.
    This will make the string pretend it's empty - even strlen will return zero.
    (The string won't really be empty, but most string functions usually think that the string ends at the first zero character)
    PHP Code:
    buf[0] = 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width