Salut à tous
j'ai creé un code C pour calculer la position d'un caractere (c) dans une chaîne (ch) mais le problème que l'application s'exécute mais il paraît qu'il y a une boucle infinie avec message Windows "pos.exe a cessé de fonctionner" et au dessous de l'IDE il y a les erreurs suivantes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 C:\test\SansNom1.c In function `pos': 10 C:\test\SansNom1.c [Warning] comparison between pointer and integer 11 C:\test\SansNom1.c [Warning] comparison between pointer and integer
et voici mon code:
aidez-moi SVP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include<stdio.h> #include<stdlib.h> #include<string.h> int pos(char c[],char ch[]) { int i=0,n=strlen(ch); do { i++; }while ((ch[i]!=c)||(i!=n)); if (ch[i]!=c){i=0;} ; return i; } int main (int argc,char *argv[]) { char c[1],ch[9999]; scanf("%s %s",ch,c); printf("%d",pos(c,ch)); getchar(); }![]()
Partager