Hello all,

I worte a structure and filled the data, then i need to send them on tcp socket. before that i need to send only few data and i need to split them into bytes and need to store them in other array.

Here is the code below

#include "stdafx.h"
#include <string.h>
#include <malloc.h>

struct Test

 int sno;
 char name[24];
 int rno;
} testexmp;

//conversion of structure into bytes
unsigned long int x;
void dumpHex ( void *p, size_t size ) 
  //int *list = malloc(n* sizeof(int));
  unsigned char *bytes = (unsigned char *)p;
  for (size_t i = 0 ; i < size ; i++ )
    unsigned int b = bytes[i];
	if (b>3)

/*    how to copy the remaining bytes into other array  */

	printf(" i=%d 0x%02x \n",i,(char*)bytes[i]);
	memcpy(&x, bytes, sizeof(long));

int main(int argc, char* argv[])

	printf("size of the test structure is %d \n",sizeof(testexmp));




	printf("sno is %d \n",testexmp.sno);
	printf("name  is %s \n",testexmp.name);
	printf("roll no is %d \n",testexmp.sno);

	return 0;

Is there a question there? Or are you just posting your code because you are very proud of it?

Your code. Iss verah nice.


>before that i need to send only few data
There's a chance that this may have been his problem, not sure though. :P