Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by nitrogen

17 years ago

sizeof() is used to determine the actual in-memory size of something for use by memcpy/malloc/etc., not the number of elements. There are commonly-used array size macros that can help with this, such as

  #define ARRAY_SIZE(x) sizeof(x)/sizeof((x)[0])

0 comments

nitrogen

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities