memset() or ZeroMemory()

This is a discussion on memset() or ZeroMemory() within the C++ Programming forums, part of the General Programming Boards category; Is either one universally preferred? The book I'm currently reading uses memset() exclusively without ever mentioning ZeroMemory() and the only ...

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    memset() or ZeroMemory()

    Is either one universally preferred? The book I'm currently reading uses memset() exclusively without ever mentioning ZeroMemory() and the only time they use memset() is to set a block of memory to 0's. Wouldn't it just be better (1 less param) to use ZeroMemory()? I haven't found anything that said ZeroMemory() was compiler or OS specific, but I was wondering if it was and that was why the author prefered memset().

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    49
    ZeroMemory is a Windows API. If you want run your program on any other platform than Windows, use memset.
    In Win32, ZeroMemeory(ptr, size) is same as memset(ptr, 0, size).
    ZeroMemeory is created by Microsoft, the reason is in 80s memset can run on real mode DOS only while Windows had ran in virtual mode.
    Hello, everyone.

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Thanks, Hotman_x. My game is being written with DirextX for the Win32 platform, so with this project portability isn't a concern.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. info on memset and recv
    By lolguy in forum Networking/Device Communication
    Replies: 15
    Last Post: 11-12-2009, 04:48 AM
  2. ZeroMemory() == memset() ?????????
    By Deo in forum C++ Programming
    Replies: 4
    Last Post: 05-27-2005, 10:44 AM
  3. problem using 'memset'
    By ezwise in forum C Programming
    Replies: 2
    Last Post: 03-17-2005, 10:27 AM
  4. Simple Question on Correct Usage of memset
    By deadpoet in forum C++ Programming
    Replies: 2
    Last Post: 03-16-2004, 07:58 AM
  5. memset has conflicting declaration
    By mangoMan in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2004, 09:08 AM

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