M
Martin Wells
I've already started a thread about this but it descended into crap
mostly because of incompetant replies.
I'll be very specific about what I'm asking, so please if you don't
know shit about C or how to code then just stay quiet.
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
Emphasis needed so people don't start posting loops as a response. You
wouldn't think I'd need to add the emphasis but hey look at the utter
shite I got back in the other thread (not all of it was shite).
UCHAR_MAX isn't guranteed to fit in an int, but maybe we'll get a
consistent result across all implementations if we use it? I'll have
to look up the rules for signed to unsigned conversions. As far as I
know though, it's something along the lines of:
target = TARGET_TYPE_MAX + 1 - negative_number
~0 is a different value on different systems, depending on the system
used to represent negative numbers.
Any other takers for what we should give memset? I think basically we
need an int value that will convert to UCHAR_MAX on every
implementation? Maybe we might have to delve into determing the number
system via macros, but I'm just thinking out loud. In the end we'd
have:
memset(data, INT_VALUE_THAT_WILL_YIELD_UCHAR_MAX, sizeof data);
Martin
mostly because of incompetant replies.
I'll be very specific about what I'm asking, so please if you don't
know shit about C or how to code then just stay quiet.
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
What argument can I give memset in order to set an entire chunk of
memory to all bits 1?
Emphasis needed so people don't start posting loops as a response. You
wouldn't think I'd need to add the emphasis but hey look at the utter
shite I got back in the other thread (not all of it was shite).
UCHAR_MAX isn't guranteed to fit in an int, but maybe we'll get a
consistent result across all implementations if we use it? I'll have
to look up the rules for signed to unsigned conversions. As far as I
know though, it's something along the lines of:
target = TARGET_TYPE_MAX + 1 - negative_number
~0 is a different value on different systems, depending on the system
used to represent negative numbers.
Any other takers for what we should give memset? I think basically we
need an int value that will convert to UCHAR_MAX on every
implementation? Maybe we might have to delve into determing the number
system via macros, but I'm just thinking out loud. In the end we'd
have:
memset(data, INT_VALUE_THAT_WILL_YIELD_UCHAR_MAX, sizeof data);
Martin