memset vs bzero

P

puzzlecracker

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
 
K

Krishanu Debnath

puzzlecracker said:
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
 
C

CBFalconer

puzzlecracker said:
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:
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
 
V

Villy Kruse

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
 
M

Mark McIntyre

On 22 Feb 2005 21:41:17 -0800, in comp.lang.c , "puzzlecracker"


(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.
 
J

James McIninch

<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).
 
R

Randy Howard

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. :)
 
C

Christian Bau

Randy Howard said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top