copying an array of bytes to another array
-
copying an array of bytes to another byte array of same size -- modified at 11:24 Friday 3rd March, 2006
-
copying an array of bytes to another byte array of same size -- modified at 11:24 Friday 3rd March, 2006
-
...and your question is? If I guess correctly, something like this would do nicely:
char pArray1[] = {1,2,3,4,5}; // Source array char pArray2[5]; // Destination array memcpy(pArray1, pArray2, 5);
I Dream of Absolute Zero
RChin wrote:
memcpy(pArray1, pArray2, 5);
Or:
memcpy(pArray2, pArray1, 5 * sizeof(char));
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
...and your question is? If I guess correctly, something like this would do nicely:
char pArray1[] = {1,2,3,4,5}; // Source array char pArray2[5]; // Destination array memcpy(pArray1, pArray2, 5);
I Dream of Absolute Zero
Its an array of Bytes, like i owuld like like to assign source array of bytes to destination array, as am getting chunks of bytes in the source array, so that i would be having all bytes without break.
-
RChin wrote:
memcpy(pArray1, pArray2, 5);
Or:
memcpy(pArray2, pArray1, 5 * sizeof(char));
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
ya thank you, it didnt work for me, i would like to assign source array to new array. eg: assinging BYTE sourcearray[212] to BYTE destarray[1024],,,, as am pieces of bytes in source array, like 108 bytes for the first time and again 104 bytes for the second time. -- modified at 11:57 Friday 3rd March, 2006
-
Its an array of Bytes, like i owuld like like to assign source array of bytes to destination array, as am getting chunks of bytes in the source array, so that i would be having all bytes without break.
memcpy()
is the function to use. What about it is not working?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
memcpy()
is the function to use. What about it is not working?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
yes, its working, but again am getting the breaks in the data as like in source array. I would like to have continous stream of data.
-
ya thank you, it didnt work for me, i would like to assign source array to new array. eg: assinging BYTE sourcearray[212] to BYTE destarray[1024],,,, as am pieces of bytes in source array, like 108 bytes for the first time and again 104 bytes for the second time. -- modified at 11:57 Friday 3rd March, 2006
chaitanya22 wrote:
i would like to assign source array to new array. eg: assinging BYTE sourcearray[212] to BYTE destarray[1024],,,,
Use:
memcpy(destarray, sourcearray, 108 * sizeof(BYTE));
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb