appending chunks of Bytes
-
Hello, am still having a problem with this appending. Am recieving data from a machine two times(i,e total lenght of recieving bytes:212) but am recieving them as length:x1 and length:x2)spliting into two chunks. count:1 //first chunk of data length:112//length si varying, not constant, say x1 0x65 0x66 0x67...... count:2// second chunk of data length:100//length si varying, not constant, say x2 0x23 0x40 0x46 0xcf.... How could i append the length of x2 bytes to x1, so that i should have total 212 bytes. i would be gald if anyone halps me out from this. BYTE buffer[1024]; BYTE array[1024];//the output data am recieving from machine is in buffer for(i=0;i<=lLength;i++) printf("#%x", buffer[i]); if(count>1) array[i]=buffer[i];//am assigning all the buffer values to array if count is greater than 1. "or" i can use memcpy() also, but there si no result; is it correct?? but i couldnt get append the whole data? could anyone plz help me for appending -- modified at 12:10 Thursday 9th March, 2006
-
Hello, am still having a problem with this appending. Am recieving data from a machine two times(i,e total lenght of recieving bytes:212) but am recieving them as length:x1 and length:x2)spliting into two chunks. count:1 //first chunk of data length:112//length si varying, not constant, say x1 0x65 0x66 0x67...... count:2// second chunk of data length:100//length si varying, not constant, say x2 0x23 0x40 0x46 0xcf.... How could i append the length of x2 bytes to x1, so that i should have total 212 bytes. i would be gald if anyone halps me out from this. BYTE buffer[1024]; BYTE array[1024];//the output data am recieving from machine is in buffer for(i=0;i<=lLength;i++) printf("#%x", buffer[i]); if(count>1) array[i]=buffer[i];//am assigning all the buffer values to array if count is greater than 1. "or" i can use memcpy() also, but there si no result; is it correct?? but i couldnt get append the whole data? could anyone plz help me for appending -- modified at 12:10 Thursday 9th March, 2006
chaitanya22 wrote:
How could i append the length of x2 bytes to x1, so that i should have total 212 bytes.
Use
memcpy()
.
"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
-
chaitanya22 wrote:
How could i append the length of x2 bytes to x1, so that i should have total 212 bytes.
Use
memcpy()
.
"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
if(count>0) memcpy(array,buffer, 213); for(int i=0;i<=length;i++) printf("%x", array[i]); if i do so, again its copying with chunks in between the data. as i should copy the buffer of count:2 to buffer of count:1, so am using array[i+lLength]=lData[i]; //from starting of next chunk for(int i=0;i<=length;i++) {printf("%x", array[i]);} is this correct???
-
if(count>0) memcpy(array,buffer, 213); for(int i=0;i<=length;i++) printf("%x", array[i]); if i do so, again its copying with chunks in between the data. as i should copy the buffer of count:2 to buffer of count:1, so am using array[i+lLength]=lData[i]; //from starting of next chunk for(int i=0;i<=length;i++) {printf("%x", array[i]);} is this correct???
Consider:
char arr1[12] = "Hello ";
char arr2[6] = "World";
memcpy(&arr1[6], arr2, 5 * sizeof(char));
// arr1 now contains "Hello World"
"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
-
Consider:
char arr1[12] = "Hello ";
char arr2[6] = "World";
memcpy(&arr1[6], arr2, 5 * sizeof(char));
// arr1 now contains "Hello World"
"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, Tahnk you for your answer. I got the solution.