im trying to split a string in C (Not in C#, C++ or any other kind). I tried using de strtok function, but it turns out that this only works when the limit between each word is a single character such a space, a semicolon….
I have a variable which is a string that contains html code like this:
</head>
<body>
Index of /davidgoudet
<ul><li><a href="/"> Parent Directory</a></li>
<li><a href="Horario/"> Horario/</a></li>
<li><a href="Oferta/"> Oferta/</a></li>
<li><a href="Registro/"> Registro/</a></li>
</ul>
<address>Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at turpialdevelopment.com Port 80</address>
</body></html>
And i want to have the chunks in between the href tags such as Horario, Oferta, Registro inside a variable
but when i tried to use strtok(string, “href”) it gives me some weird result which is not the one im looking for.
Any ideas?
Thanks
strtoktakes a char array of all possible delimiters and it splits based on any of those characters (in your case, splitting onh,r,e, orf), which is probably why you are seeing weird behavior.Is there a reason why you aren’t using an HTML parsing library to pull the names?
the libxml html parser is pretty good: http://www.xmlsoft.org/html/libxml-HTMLparser.html