Hi,
i am little confused in usage of strtok() syntax. Basically , i extracted the source code of a webpage using Java and now i have to remove all the extra tags inside the html page so i can have clear text. For example a simple HTML page is like
<html>
<Title>
My Page
</title>
</html>
Now in the above example i want all the tags to be removed and i want to print the text of the page in file , like "My Page " in file2. i have written the code but forsome reason it is removing the text instead of text, secondly i am very confused abt the use of strtok, so i will appreciate some guidance on this.
Code:
#include<stdio.h>
#include<stdlib.h>
FILE *f1,*f2;
int main()
{
char x[0xFFF]; // = 4095 as size of char array
char *ptr1=NULL;
f1 = fopen ("result.dat" , "r");
f2 = fopen("result1.dat","w");
if (f1== NULL)
{
printf("\nSorry but there is no file on disk known as result");
exit(1);
}
while (fgets(x,0xFFE,f1)!=NULL)
{
ptr1 = strtok(x,"<");
while (ptr1 !=NULL)
{
fprintf(f2,"\n%s", x);
ptr1 = strtok(NULL ,">");
}
}
fclose(f1);
fclose(f2);
return 0;
}