Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • But that doesn't explain the 12 2... nevertheless +1 Commented Jul 10, 2013 at 7:35
  • 3
    @glglgl The “12 2” is probably explained by size_t being 64-bit and invoking undefined behavior when passed to printf with a %d format, as per my comment. Commented Jul 10, 2013 at 7:37
  • @PascalCuoq This might be the case, but then I'd rather expect a 0 somewhere, no matter if little or big endian... But one never knows what strange things the one or other platform makes. Commented Jul 10, 2013 at 7:39
  • 2
    If your implementation supports it, use "%zu" to print a size_t value. If it doesn't (Microsoft likely doesn't), use "%lu" and convert the value to unsigned long. Or, if you're lazy and the values are known to be small, use "%d" and convert to int. Commented Jul 15, 2013 at 20:16
  • The unconventional values may also be the result of not including a proper prototype for printf in the program, and so the system applied the variable argument macros to something random. Commented May 22, 2018 at 5:39