R
Randy Graham
While reviewing someone else's c++ code recently I was horrified to find
something like this:
(example only)
A.
char a[10];
memset(&a, 0, 10);
memcy(&a, "hello", 6);
Of course this is wrong, and should be
B.
char a[10];
memset(a, 0, 10);
memcy(a, "hello", 6);
When I brought this up with the author, he insisted he had always done
this and it worked.
When I tried it with VC++ 8.0 to show him he was nuts, it did in fact
compile and appear to function correctly.
Why would this work, passing a pointer to the pointer to the char array
(A.) when the pointer should be passed (B.).
A. is clearly wrong.
I don't get it.
-Randy
something like this:
(example only)
A.
char a[10];
memset(&a, 0, 10);
memcy(&a, "hello", 6);
Of course this is wrong, and should be
B.
char a[10];
memset(a, 0, 10);
memcy(a, "hello", 6);
When I brought this up with the author, he insisted he had always done
this and it worked.
When I tried it with VC++ 8.0 to show him he was nuts, it did in fact
compile and appear to function correctly.
Why would this work, passing a pointer to the pointer to the char array
(A.) when the pointer should be passed (B.).
A. is clearly wrong.
I don't get it.
-Randy