Home > Back-end >  Consult to traverse the list why do I get the value of the char * type is not correct, such as plast
Consult to traverse the list why do I get the value of the char * type is not correct, such as plast

Time:01-23

Typedef struct QElemPcm
{
Int indexnumber;//serial number
Char datatime [20].//time
Int64_t ltimetv_usec;//timestamp
Char * Pcm_data;//data
Int bufflen;//data length
} QElemPcm;

Typedef list LIST_QElemPcm;//

LIST_QElemPcm list_pcm;//

Save and load the list data

Printf (" the raw data: [% d] \ n ", bufflen);
For (int I=0; I & lt; Bufflen; I++)
Printf (" % 2 "x, sPcmdata [I]);
printf("\n");
The fflush (stdout);

Struct timeval TV;
The gettimeofday (& amp; TV, NULL);
Int64_t ltimeNowtime=(long long) TV. Tv_sec) * 1000 + TV. Tv_usec/1000;
QElemPcm tmpQElemPcm;
TmpQElemPcm. Indexnumber=irecord;
TmpQElemPcm. Ltimetv_usec=ltimeNowtime;
tmpQElemPcm. Pcm_data=https://bbs.csdn.net/topics/(char *) malloc (1024);//define a pointer, and allocates memory unit

Memcpy (tmpQElemPcm Pcm_data sPcmdata, bufflen);


TmpQElemPcm. Bufflen=bufflen;

List_pcm. Push_back (tmpQElemPcm);
Free (tmpQElemPcm. Pcm_data);


Traverse the list reads data
Char * s_outBuf=(char *) malloc (4096);//define a pointer, and allocates memory unit
For (LIST_QElemPcm: : iterator lit=list_pcm. The begin (); Lit!=list_pcm. End ())//this is key, overloading==it's a good idea to not
{

Char tmppcm_time [20].
Memset (tmppcm_time, 0, sizeof (tmppcm_time));

Sprintf (tmppcm_time, "% LLD," (* lit). Ltimetv_usec);
memcpy (s_outBuf, lit (*). Pcm_data, lit (*). Bufflen);
Printf (" traversal data: [% d] [% d]] [% s \ n ", (* lit). Bufflen, lit (*). Indexnumber, tmppcm_time);
For (int I=0; I & lt; (* lit). Bufflen; I++)
Printf (" % 2 "x, s_outBuf [I]);
printf("\n");
The fflush (stdout);

Lit=list_pcm. Erase (lit);//delete and return a pointer to the next
}
Free (s_outBuf);



Why I read data is

00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FE FF FE FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 FF FF FF FF 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 00 00 FF FF FF FF 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- irecord=[4] ltime=[1611307017569]







Read the




Traversing the data: [960] [4] [1611307017569]
nullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related