Traitement de chaine langage C
Résolu/Fermé
LaZo61
Messages postés
53
Date d'inscription
jeudi 1 février 2007
Statut
Membre
Dernière intervention
24 mai 2007
-
18 mai 2007 à 09:36
mamiemando Messages postés 32283 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 17 mars 2023 - 18 mai 2007 à 14:17
mamiemando Messages postés 32283 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 17 mars 2023 - 18 mai 2007 à 14:17
A voir également:
- Traitement de chaine langage C
- Plus de chaine tv - Guide
- Et en langage c - Astuces et Solutions
- Excel extraire chaine de caractère après un caractère ✓ - Forum Excel
- Youtube traitement de la version hd en cours ✓ - Forum Internet / Réseaux sociaux
- Traitement de texte gratuit - Guide
1 réponse
mamiemando
Messages postés
32283
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
17 mars 2023
7 572
18 mai 2007 à 14:17
18 mai 2007 à 14:17
http://www.linux-kheops.com/doc/man/manfr/man-ascii-0.9/man3/strncmp.3.txt.html
Bonne chance
#include <string.h>
#include <stdio.h>
int main(){
const char *str1 = "cellelasdsdsads";
const char *str2 = "plop";
const char *pattern = "cellela";
if(strncmp(pattern,str1,strlen(pattern)) == 0){
printf("%s commence par %s\n",str1,pattern);
}else{
printf("%s ne commence pas par %s\n",str1,pattern);
}
if(strncmp(pattern,str2,strlen(pattern)) == 0){
printf("%s commence par %s\n",str2,pattern);
}else{
printf("%s ne commence pas par %s\n",str2,pattern);
}
return 0;
}
Bonne chance