#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <string.h> #include <unistd.h> int main() { FILE *fd; char buff[1024]; char *str; fd = fopen("taskd.xml", "r"); if(fd == NULL) { perror("open"); } while (strstr(buff, "</ROOT>") == NULL) { fgets(buff, 1024, (FILE*)fd); usleep(1000); if(strstr(buff, "<TASK>") != NULL) { str = (char *)malloc(20); memset(str, 0, 20); memcpy(str, buff+7, 6); printf("%s\n", str); free(str); } } fclose(fd); return 0; }