memset vs bzero

Discussion in 'C Programming' started by puzzlecracker, Feb 23, 2005.

  1. I have seen these two functions used interchangeably and could never
    fully discern their meaning, nor could understand the particular
    preference to either one.

    Could someone be kind enough to explain that (or least to direct me to
    a good source)?


    thanks
     
    puzzlecracker, Feb 23, 2005
    #1
    1. Advertising

  2. puzzlecracker wrote:

    >I have seen these two functions used interchangeably and could never
    >fully discern their meaning, nor could understand the particular
    >preference to either one.
    >
    > Could someone be kind enough to explain that (or least to direct me to
    >a good source)?
    >
    >
    >thanks
    >
    >
    >

    bzero can only be used to reset memory location. Besides that bzero is
    not a standard function.

    Krishanu
     
    Krishanu Debnath, Feb 23, 2005
    #2
    1. Advertising

  3. puzzlecracker

    CBFalconer Guest

    puzzlecracker wrote:
    >
    > I have seen these two functions used interchangeably and could
    > never fully discern their meaning, nor could understand the
    > particular preference to either one.
    >
    > Could someone be kind enough to explain that (or least to direct
    > me to a good source)?


    The function bzero() does not exist in standard C. To use it you
    have to define it first. Memset, on the other hand, pre-exists and
    has a known meaning.

    --
    Some informative links:
    news:news.announce.newusers
    http://www.geocities.com/nnqweb/
    http://www.catb.org/~esr/faqs/smart-questions.html
    http://www.caliburn.nl/topposting.html
    http://www.netmeister.org/news/learn2quote.html
     
    CBFalconer, Feb 23, 2005
    #3
  4. puzzlecracker

    Villy Kruse Guest

    On 22 Feb 2005 21:41:17 -0800,
    puzzlecracker <> wrote:


    > I have seen these two functions used interchangeably and could never
    > fully discern their meaning, nor could understand the particular
    > preference to either one.
    >


    bzero was found on BSD unix, meset on AT&T unix. memset was
    adopted by the ANSI C and POSIX standards and bzero deprecated.


    Villy
     
    Villy Kruse, Feb 23, 2005
    #4
  5. On 22 Feb 2005 21:41:17 -0800, in comp.lang.c , "puzzlecracker"
    <> wrote:


    (a statement without qa subject)

    please put your question entirely in the mesage body. Not all newsreaders
    display the 'subject' line right next to the body, and you should not
    expect your readers to have to bob about to discover what you're talking
    about.

    By the way, bzero is nonstandard, and you should use memset.

    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Feb 23, 2005
    #5
  6. <posted & mailed>

    C has memset(), the Berkeley UNIX C library has bzero(). They are not
    identical, and bzero() predates memset() but is not widely available (since
    it's not part of standard C).

    puzzlecracker wrote:

    > I have seen these two functions used interchangeably and could never
    > fully discern their meaning, nor could understand the particular
    > preference to either one.
    >
    > Could someone be kind enough to explain that (or least to direct me to
    > a good source)?
    >
    >
    > thanks


    --
    Remove '.nospam' from e-mail address to reply by e-mail
     
    James McIninch, Feb 23, 2005
    #6
  7. puzzlecracker

    Randy Howard Guest

    In article <>,
    says...
    > bzero() predates memset() but is not widely available (since
    > it's not part of standard C).


    Well, it's supported on every Linux platform on the planet, if that
    helps. :)

    --
    Randy Howard (2reply remove FOOBAR)
    "Making it hard to do stupid things often makes it hard
    to do smart ones too." -- Andrew Koenig
     
    Randy Howard, Feb 23, 2005
    #7
  8. On Wed, 23 Feb 2005 20:01:41 GMT, in comp.lang.c , Randy Howard
    <> wrote:

    >In article <>,
    > says...
    >> bzero() predates memset() but is not widely available (since
    >> it's not part of standard C).

    >
    >Well, it's supported on every Linux platform on the planet, if that
    >helps. :)


    which still doesn't count as widely available, for what its worth.

    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Feb 23, 2005
    #8
  9. In article <>,
    Randy Howard <> wrote:

    > In article <>,
    > says...
    > > bzero() predates memset() but is not widely available (since
    > > it's not part of standard C).

    >
    > Well, it's supported on every Linux platform on the planet, if that
    > helps. :)


    So it is quite useful for people who want to write Linux-only,
    non-portable code instead of writing portable code.
     
    Christian Bau, Feb 26, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. k-man
    Replies:
    4
    Views:
    4,564
    Shelley Hebert
    Dec 18, 2003
  2. Joe C
    Replies:
    5
    Views:
    8,996
    tom_usenet
    Aug 24, 2004
  3. Replies:
    17
    Views:
    6,618
    Greg Comeau
    Sep 22, 2004
  4. Guest
    Replies:
    0
    Views:
    418
    Guest
    Sep 23, 2004
  5. Guest
    Replies:
    1
    Views:
    453
    Ron Natalie
    Sep 23, 2004
Loading...

Share This Page