Lame Duck said:
I really find it hard to understand the bile and negativity that seems
to be this Group's bread and butter! I've read any number of Groups and
Forums and by and large they're all pretty friendly places, but here all
I've got is a torrent of abuse!
You have been advised repeatedly, and in many cases quite politely,
that your question is about C++, not about C, and that you should post
it in comp.lang.c++, not in comp.lang.c. And yet you persist in
posting to comp.lang.c.
You are being rude. It's not surprising that some people here in
comp.lang.c are rude to you in response. There *may* have been some
overreaction; I suggest you ignore it and move on.
It should be obvious by now that you're *not* going to get any useful
responses from comp.lang.c. I don't know what you expect to
accomplish by continuing to post here.
[...]
I really don't understand what this code is doing! I think you
misunderstood my question - &MyVector.front() already works, the problem
is to convert pointer/array to vector without having to copy all data by
hand.
Don't worry about understanding the code; the author was being
sarcastic. He was *pretending* that your question is a valid question
about C (it must have been, since you posted it to comp.lang.c).
Since C doesn't have "vectors", he invented a set of C declarations
for which "&MyVector.front()" would be valid C. The fact that the
resulting code doesn't address your problem is a result of your
posting your question to the wrong newsgroup. (He sprinkled the code
with C++ keywords used as identifiers, guaranteeing that it's not
valid C++, just to emphasize the point.)
Incidentally, I can't tell who wrote the code because you deleted the
attribution lines. Please don't do that.
Your real question, I think, is how to copy the contents of an array
into a C++ vector without copying each element individually. (I don't
know the answer to that, since I'm not sufficiently familiar with C++.
It may well be that the best solution is to copy the elements one at a
time in a loop. Or perhaps std::vector provides an operation to do
what you want in one fell swoop, though such an operation probably
works internally by looping over the elements.) You should ask *that*
question, and you should ask it in comp.lang.c++, where it's perfectly
topical. You'll probably get numerous excellent and well-informed
answers. You might even get some good advice on how to re-structure
your code so the operation you're looking for isn't needed in the
first place.
I suggest starting a new thread in comp.lang.c++, since this one's
signal-to-noise ratio has degraded considerably.
Or you can continue to waste everyone's time by whining about how rude
we've been to you. It's up to you.