Re: store contents of structure into an array



n00dle wrote:

hi,
   see if i want to copy the contents of a char arrary into a equally
size struct, assuming that the structure has no holes, padding etc., i
can use

structure = *(t_structure *) array;

but if i want to do things the other way round i.e. copy contents of
the structure to an char array. do i specifically need to have a loop
to do so, or is there a more elegant way to do it.

in case i am not clear have a look at the code below.


memcpy if the memory doesn't overlap, memmove if it might.

-David
.



Relevant Pages

  • Re: TIME TO TAKE MATTERS INTO MY OWN HANDS
    ... they'd just saw the loop off one end and put it on another. ... I didn't like dealing with the jeweler. ... drill two holes in the back, above and below where the chain wants to go ... form a rounded 'staple' of brass wire that just fits the holes ...
    (rec.crafts.jewelry)
  • RE: generic strncpy - off-by-one error
    ... of the second loop needs an explicit comparison with -1, ... second loop). ... > upon exiting the first loop. ... > This is only a win for relatively long nul padding. ...
    (Linux-Kernel)
  • Re: Springtime for ubilicals and tubeheads
    ... loop. ... Before I had the use of a proper metalworking shop, ... choose round connectors - the holes are easier to produce with a stepped ...
    (uk.rec.audio)
  • Re: ifft results in a complex number, how?
    ... iv changed the range and padding bit to; ... think i need to create some sort of for loop that incriments a ... real of the ifft it plots the correct output i think! ...
    (comp.soft-sys.matlab)
  • Re: Mneson announcement and help request
    ... > end loop; ... I know that Ada does not allow a goto into a loop; ... I know that Ada does not have a while at the and of a loop. ... where several small groups with large holes in between. ...
    (comp.lang.ada)