src是好的,但是memcpy的dst就是空的,不知道哪里出了问题,求指点。
#include <stdio.h>
#include <string.h>
#define len 20
char *BDS_TIME;
char *BDS_DATE;
char* p[len];
int i;
char uart3[60]={'$','G','N','R','M','C',',','0','2','2','4','5','6',',','V',',',',',',',',',',',',',',','1','7','0','8','2','1',',',',',',','M'};
void finddata(char* pending);
int main()
{
finddata(uart3);
return 0;
}
void finddata(char* pending)
{
p[0]=strtok(pending,",");
if(p!=NULL)
{
for(i=1;i<len;i++)
{
p[i]=strtok(NULL,",");
if(p==NULL)
{
break;
}
}
}
// printf("%s,%s",p[1],p[3]);
memcpy(BDS_TIME,p[1],6);
memcpy(BDS_DATE,p[3],6);
printf("%s,%s\r\n",BDS_TIME,BDS_DATE);
}