A
anonymous
Hi folks,
I am in a fix trying to copy data to an array which is member of a
structure. What I am doing right now is:
char array[8] = {0,1,2,3,4,5,6,7};
memcpy(structure.array, array, 8);
Is there a nicer way of doing this in a single statement?
One way that I can think of is to use
memcpy(structure.array, "\x0\x1\x2\x3\x4\x5\x6\x7", 8);
However, what if I don't want to use hex numbers. For example, if
I want to copy 77, 18, 28, 23, 88, 253, 43, 36 decimals to
structure.array[8], I would not like to first convert all these
numbers to hex. How do I do this without having to use another
variable.
Thanks in advance for any help.
I am in a fix trying to copy data to an array which is member of a
structure. What I am doing right now is:
char array[8] = {0,1,2,3,4,5,6,7};
memcpy(structure.array, array, 8);
Is there a nicer way of doing this in a single statement?
One way that I can think of is to use
memcpy(structure.array, "\x0\x1\x2\x3\x4\x5\x6\x7", 8);
However, what if I don't want to use hex numbers. For example, if
I want to copy 77, 18, 28, 23, 88, 253, 43, 36 decimals to
structure.array[8], I would not like to first convert all these
numbers to hex. How do I do this without having to use another
variable.
Thanks in advance for any help.