Quand je disais: dommage qu'il n'y a pas la possibilité de choisir un point de départ.
Je parlais de simplification à ceci:
int position_contenu_fin = (strstr(code_html, fermeture) - code_html);
devient
1 2
| int position_point_de_départ=1234;
int position_contenu_fin = (strstr(code_html, fermeture, position_point_de_départ) - code_html); |
Ancien code:
1 2 3 4
|
char code_html[500] = "</div><div class=\"texte\">ca marche bien</div><div class=\"autre\">ca marche pas</div>";
int position_de_debut = (strstr(code_html, ouverture) - code_html);
int position_de_fin = (strstr(code_html, fermeture) - code_html); |
position_de_debut aurait eu la position 6
position_de_fin aurait eu la position 0
la position_de_fin désirer est celui de la position 39, car c'est le div fermant du div class texte qui contient le contenu désirer, donc faudra coder plus pour atteindre l'objectif
Nouveu code:
1 2 3 4
|
char code_html[500] = "</div><div class=\"texte\">ca marche bien</div><div class=\"autre\">ca marche pas</div>";
int position_de_debut = (strstr(code_html, ouverture, 0) - code_html);
int position_de_fin = (strstr(code_html, fermeture, position_de_debut) - code_html); |
position_de_debut aurait eu la position 6
position_de_fin aurait eu la position 39
Partager