我用tlv格式读取xml文件,xml文件有593字节,我读下面的代码。第一个512字节为真,但其余字节为假。我读剩下的字节是00.
int fd,ret;
unsigned char *filebuffer[6400];
fd = open("filename" , O_RDONLY);
printf("file open return value : %d \n", fd);
if (fd == -1)
{
printf("Error in openning the file!\n");
exit(0);
}
//read the file
int i = 0;
do {
ret = read(fd,&filebuffer[i],512);
printf("file read return value : %d \n", ret);
if (ret == -1)
{
printf("Error in reading!\n");
exit(0);
}
i += ret;
printf("i = %d, ret = %d",i,ret);
} while (ret > 0);
int k;
char tmp[6400];
memcpy(tmp,filebuffer,i);
printf("file buffer\n");
for (k = 0; k < i; ++k) {
printf("%02x",tmp[i]);
}
close(fd);}
我正在读取文件缓冲区,我正在读取xml文件。 filebuffer示例; filebuffer:1F0583212 .....(512字节)000000
答案 0 :(得分:1)
test = strtok (writable," ,.-");
test = strtok (NULL," ,.-");
test = strtok (NULL," ,.-");
test = strtok (NULL," ,.-");
test = strtok (NULL," ,.-");
test = strtok (NULL," ,.-");
的定义不正确。将其更改为:
filebuffer