Copy array of structs in one go

D

dude.jimbo

Op woensdag 16 april 2014 10:13:49 UTC+2 schreef David Brown:
So you think Google is evil, and therefore try to use their service -

without them charging you - in such a way as to minimise /their/ income.

That's a pretty hypocritical definition of "evil". If you want to take

advantage of Google's services, you should be happy that they have an

income (within reason) so that they can give you those services.

Some smart bloke (m/f) on Usenet once said: "Sometimes people in this group
have limited auto-detect in their sense of humour."

So obviously I don't think that Google is evil (otoh, do not get me started
on Apple), nor do I sit at the PC while barking at the moon (at least not
before the bottle of scotch is empty). I am, after all, using their browser,
and their search engine, which is what - once - got me to this place in the
first place, ~and~ their usenet-interface (and I really don't _do_ Usenet
enough to switch to a proper newsreader. In fact, I've never done usenet *at
all* - you are free to feel I'm lazy, or downright arrogant about that
decision; and you'd be right, as a matter of fact).

So, if you look at the above quote from the Google I/F, you are easily led to
believe that they get money for those extra line-feeds. I mean "when you
simultaneously poke your funny-bone", that is. So I tried taking them out
(with a macro. In Notepad++. No, I don't have life) in order not to flood
anybodies screen, because I'm really one of the good guys (I mean, just look
at my opinion on Apple), but apparently that took out a header (or sumthing)
too. And for that, I do apologize. Hopefully, this time it does ~not~ go wrong
again. If it does, I'll just blame Google again. For clarity: :). (Which
reminds me: that ~really~ ruins the joke - especially when they're already
as bad as mine).

A-n-y-w-a-y, al this because I had to copy an array. In C. For the first time
in 10 years or so (OK, I'm mainly an "architect" so I don't do this writing
thing very often). There's probably a good reason why it took 10 years for this
silly thing to pop up: there really should never ever be any reason to be
copying same-sized arrays. I mean seriously, is memory and processor time
for free these days!? (Note: "it ain't _my_ design, darnit!").

But since it's not my code (major warning bell, right there <---), and since
I wouldn't have the time (not the mention the authority) to be changing all
that, here I am, failing badly at trying to be funny, failing at directly
copying an array, and discovering that a = b does indeed no worky when a and b
are arrays of the same type. Which was very educational.

And yes: I 'fixed' it with the memcpy (with a "sizeof(dest)", matter of factly,
since I also couldn't "bury" the arrays in an accompanying struct).

Jimbo
 
D

dude.jimbo

Op woensdag 16 april 2014 10:13:49 UTC+2 schreef David Brown:
So you think Google is evil, and therefore try to use their service -

without them charging you - in such a way as to minimise /their/ income.

That's a pretty hypocritical definition of "evil". If you want to take

advantage of Google's services, you should be happy that they have an

income (within reason) so that they can give you those services.

Some smart bloke (m/f) on Usenet once said: "Sometimes people in this group
have limited auto-detect in their sense of humour."

So obviously I don't think that Google is evil (otoh, do not get me started
on Apple), nor do I sit at the PC while barking at the moon (at least not
before the bottle of scotch is empty). I am, after all, using their browser,
and their search engine, which is what - once - got me to this place in the
first place, ~and~ their usenet-interface (and I really don't _do_ Usenet
enough to switch to a proper newsreader. In fact, I've never done usenet *at
all* - you are free to feel I'm lazy, or downright arrogant about that
decision; and you'd be right, as a matter of fact).

So, if you look at the above quote from the Google I/F, you are easily led to
believe that they get money for those extra line-feeds. I mean "when you
simultaneously poke your funny-bone", that is. So I tried taking them out
(with a macro. In Notepad++. No, I don't have life) in order not to flood
anybodies screen, because I'm really one of the good guys (I mean, just look
at my opinion on Apple), but apparently that took out a header (or sumthing)
too. And for that, I do apologize. Hopefully, this time it does ~not~ go wrong
again. If it does, I'll just blame Google again. For clarity: :). (Which
reminds me: that ~really~ ruins the joke - especially when they're already
as bad as mine).

A-n-y-w-a-y, al this because I had to copy an array. In C. For the first time
in 10 years or so (OK, I'm mainly an "architect" so I don't do this writing
thing very often). There's probably a good reason why it took 10 years for this
silly thing to pop up: there really should never ever be any reason to be
copying same-sized arrays. I mean seriously, is memory and processor time
for free these days!? (Note: "it ain't _my_ design, darnit!").

But since it's not my code (major warning bell, right there <---), and since
I wouldn't have the time (not the mention the authority) to be changing all
that, here I am, failing badly at trying to be funny, failing at directly
copying an array, and discovering that a = b does indeed no worky when a and b
are arrays of the same type. Which was very educational.

And yes: I 'fixed' it with the memcpy (with a "sizeof(dest)", matter of factly,
since I also couldn't "bury" the arrays in an accompanying struct).

Jimbo
 
J

James Kuyper

Sometimes people in this group have limited auto-detect in their sense
of humour. ...

While true, don't overestimate the importance of that possibility. It
was quite easy to detect that this guy was joking around with virtually
every sentence he wrote. The jokes weren't particularly funny - but they
also seemed motivated by insecurity based upon a very real ignorance.
It's entirely possible to read his comment about BOOL, recognise that it
was intended to be funny, and yet also recognise that it reflected a
misapprehension about BOOL being problematic. Those "discussions around
the coffee machine" were probably not with a true C guru with a gift for
explaining things clearly, or Jimbo wouldn't be coming here for advice.
 
D

David Brown

While true, don't overestimate the importance of that possibility. It
was quite easy to detect that this guy was joking around with virtually
every sentence he wrote. The jokes weren't particularly funny - but they
also seemed motivated by insecurity based upon a very real ignorance.
It's entirely possible to read his comment about BOOL, recognise that it
was intended to be funny, and yet also recognise that it reflected a
misapprehension about BOOL being problematic. Those "discussions around
the coffee machine" were probably not with a true C guru with a gift for
explaining things clearly, or Jimbo wouldn't be coming here for advice.

I agree entirely here. We know from past threads here in c.l.c. that
booleans in C can be a source of confusion and controversy, even amongst
the most experienced programmers.
 
K

Keith Thompson

David Brown said:
Get a real newsreader - there are plenty of good newsreader programs.
And there are plenty of free newsservers. I don't want to start a "my
newsreader is better than your newsreader" thread, but there is almost
universal agreement that Google's Usenet interface is the worst choice.
I use Thunderbird and news.external-september.org. Some people might
prefer other newsreaders and news servers, but that should get you started.

It's news.eternal-september.org (no 'x').
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,179
Latest member
pkhumanis73
Top