Copy array of structs in one go

Discussion in 'C Programming' started by dude.jimbo, Apr 15, 2014.

  1. dude.jimbo

    dude.jimbo Guest

    Op woensdag 16 april 2014 10:13:49 UTC+2 schreef David Brown:
    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
     
    dude.jimbo, Apr 16, 2014
    #21
    1. Advertisements

  2. dude.jimbo

    dude.jimbo Guest

    Op woensdag 16 april 2014 10:13:49 UTC+2 schreef David Brown:
    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
     
    dude.jimbo, Apr 16, 2014
    #22
    1. Advertisements

  3. dude.jimbo

    James Kuyper Guest

    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.
     
    James Kuyper, Apr 16, 2014
    #23
  4. dude.jimbo

    David Brown Guest

    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.
     
    David Brown, Apr 16, 2014
    #24
  5. It's news.eternal-september.org (no 'x').
     
    Keith Thompson, Apr 16, 2014
    #25
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.