1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char *ouverture = "<div class=\"texte\">";
char *fermeture = "</div>";
char code_html[500] = "<div class=\"menu\">ca marche pas</div>\n<div class=\"texte\">ca marche bien</div>\n<div class=\"autre\">ca marche pas</div>";
printf("étape 1:\n%s\n\n", code_html);
int position_contenu_debut = (strstr(code_html, ouverture) - code_html) + strlen(ouverture);
int j = 0;
for(int i = position_contenu_debut; i <= strlen(code_html); i++){
code_html[j]=code_html[i];
j++;
}
printf("étape 2:\n%s\n\n", code_html);
int position_contenu_fin = (strstr(code_html, fermeture) - code_html);
for(int i = position_contenu_fin; i < strlen(code_html); i++){
code_html[i]='\0';
}
printf("étape 3:\n%s", code_html);
return 0;
} |