一行一行读取文件,并把每一行按照特定字符拆分开
int dev_list_change()
{
FILE *fd;
char buf[256] = {0};
int len;
char *p;
fd = fopen(FILE_PATH,"r");
if (NULL == fd)
{
printf("open failed\n");
return -1;
}
while (NULL != fgets(buf, 128, fd))
{
len = strlen(buf);
buf[len - 1] = '\0';
printf("%s\n", buf);
p = strtok(buf, "; ");
printf("%s\n", p);
while ((p = strtok(NULL, "; ")))
{
printf("%s\n", p);
}
}
fclose(fd);
return 0;
}
int main()
{
int i = 0;
dev_list_change();
}