Hi All,
In the following:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/memcpy-s-wmemcpy-s?view=msvc-170
C
errno_t memcpy_s(
void *dest,
size_t destSize,
const void *src,
size_t count
);
What exactly is a "const void *src"?
Many thanks,
-T
...What exactly is a "const void *src"?
M$ answered this one for me:
T,
...What exactly is a "const void *src"?
M$ answered this one for me:Now the only thing you need to consider is /why/. Why does the source has
a "const" prefix, but the destination does not need it. What does it
/mean/.
IOW, you have *some* , but not *the* answer.
And no, I've got no idea myself.
And no, I've got no idea myself.
You have some funny blind spots, Rudy!
(Just to clarify, it determines whether the memory they point at can be altered)
Both are void pointers because at this stage we are not worrying
about exactly what is stored in the memory.
In my opinion this is a confusing use of the word "void"
(Just to clarify, it determines whether the memory they point at can be altered)
Thats odd, as I have no problem with altering the memory "src" is pointing at. Before, or after (have not tried during) that memcpy will do/has done its thing.
IOW, there is a reason I have no idea, as it doesn't make any sense to me that a function tells / can tell me what I can or can't do with two memory blocks I own. Can you explain ?
On 12/1/22 06:18, Paul N wrote:
In my opinion this is a confusing use of the word "void""Void" always gets me too.
I see it as a pointer that can point to any type
of structure.
void
adjective
Containing no matter; empty.
Not occupied; unfilled.
Completely lacking; devoid: synonym: empty.
Real bad name to have picked.
It's not telling you what you can or can't do, memcpy_s is promising that *it*
won't alter the memory pointed to by src
moment, it's a pointer to something and we don't care for the moment what the "something" is.I see it as a pointer that can point to any typeYes, that's right. I sometimes think of it as "a pointer wrapped in a blanket". At some point in the past the value was used to actually put something into memory. At some point in the future it will be used to fish something out of memory. But at the
of structure.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 41:59:59 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,792 |