Thread: ZeroMemory() == memset() ?????????

  1. #1
    Registered User
    Join Date
    May 2005

    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
    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
    It is, on 32 bit system. winnt.h contains a line like
    #define ZeroMemory(p, sz) memset((p), 0, (sz))
    All the buzzt!

    "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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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.

  5. #5
    Registered User
    Join Date
    May 2005


    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, 02: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