ZeroMemory() == memset() ?????????

This is a discussion on ZeroMemory() == memset() ????????? within the C++ Programming forums, part of the General Programming Boards category; Wondering if these two function accomplish the same task or not? Just wanted to clarify before I run into possible ...

  1. #1
    Deo
    Deo is offline
    Registered User
    Join Date
    May 2005
    Posts
    73

    ZeroMemory() == memset() ?????????

    Wondering if these two function accomplish the same task or not? Just wanted to clarify before I run into possible problems down the road.

    ZeroMemory( &d3dpp,sizeof(d3dpp));

    equivalent to

    memset(&d3dpp, 0, sizeof(d3dpp));

    ???????

    thnx for any clarification.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    yes, they do

    I'm not sure, but I think I remember ZeroMemory being a macro containing a memset.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    It is, on 32 bit system. winnt.h contains a line like
    #define ZeroMemory(p, sz) memset((p), 0, (sz))
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,497
    memset() is far more portable than the other one.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Deo
    Deo is offline
    Registered User
    Join Date
    May 2005
    Posts
    73

    Thnks

    Thanks for the info...

    I decided to go with memset() as I had used it before, but considering the examples showed ZeroMemory() I was unsure if I was messing something up...

    good to know they are the same and I can stick with memset().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Homework help
    By mkdl750 in forum C Programming
    Replies: 45
    Last Post: 07-17-2008, 09:44 PM
  3. Separate long string into multiple arrays
    By cashmerelc in forum C Programming
    Replies: 6
    Last Post: 11-27-2007, 01:57 AM
  4. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 09:50 PM
  5. Need help with Tic Tac Toe
    By Zerostatic in forum C++ Programming
    Replies: 19
    Last Post: 07-19-2002, 07:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21