Thursday, 15 August 2013

getting garbage while rerive from unsigned char array

getting garbage while rerive from unsigned char array

Getting garbage in output, don't know what is going on here :
I am trying to get data from the binary buffer whose format of data is int
,int,int,int,double,double,double,char[25] and im getting garbage
void printBuffer(char* bufferpass)
{
int i,j,idata;
double ddata;
char cdata[24];
unsigned char* p;
char* tempch;
int start;
for(i=0;i<noofattr;i++)
{
switch(attributes[i][0])
{
case 1:
start=offsetCount[i];
memcpy(&idata,bufferpass+offsetCount[i],attributes[i][1]);
printf("\ninteger value size=> %d ",idata);
break;
case 2:
memcpy(&ddata,bufferpass+offsetCount[i],attributes[i][1]);
printf("\ndouble value => %f ",ddata);
break;
case 3:
start=offsetCount[i];
memcpy(&cdata,bufferpass+offsetCount[i],attributes[i][1]);
printf("\nchar value=> %s ",cdata);
break;
}
}
getchar();
}

No comments:

Post a Comment