Bonjour à tous,

J'ai écris un prg qui fait un controle sur une chaine de caractère qui doit être du type : (espace)<chaine>(espace)
Au niveau de mon prg principale, toutes les instructions apres le else de la condition : if (!(espace(mot[rang]))) ne sont pas excuté.

SVP, aidez moi a trouver une solution !!!!

Merci d'avance!!!!

Voici le code ci-dessous :
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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
 
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
 
 
//// Fonction espace //////
 
int espace(char a)
 
{
if (a==' ')
   return 1;
else
   return 0;
}
 
 
/////Fonction Element de G ////
 
int ElementG (char a)
{
if (isalpha(a))
   return  1;
else
   return  0;
}
 
 
//// Fonction Element de F ///
 
int ElementF (char a)
{
 if ((isalpha)&&(isdigit))
    return 1;
 else
    return 0;
}
 
//// Procedure Etat2 ////////
 
void etat2(char mot[], int L, int rang, int vide, int appG)
 
{
 while ((rang<=L) && (espace(mot[rang])))
 {
    rang++;
 }
 if (rang>L)
     vide=1;
 else
     vide=0;
 
 if (!vide)
    {
       appG=ElementG(mot[rang]);
    }
 }
 
 ///// Procedure etat3 /////////
 
 void etat3(char mot[], int n, int max, int rang, int longueur, int tropc, int blanc, int sortie, int appF)
 
 {
  while ((rang<=n)&&(longueur<=max)&&(ElementF(mot[rang])))
  {
  rang++;
  longueur++;
  }
 
  if (rang>n)
     sortie=1;
  else
     sortie=0;
 
  if (!sortie)
  {
  if (longueur>max)
     tropc=1;
  else
     tropc=0;
 
  if (espace(mot[rang]))
     blanc=1;
  else
     blanc=0;
 
  appF=ElementF(mot[rang]);
  }
 
 }
 
 /////////// PROGRAMME PRINCIPALE ////////////
 
void  main ()
 {
 char mot[20]; char motval; char choix;
 int n,rang,longueur, maxi, longmax, sortis, blancs, vide, appG,appF;
 
 do
 {
 //clrscr();
 
 printf ("Entrer le nombre max de caracteres :");
 scanf("%s",maxi);
 
 
 printf("Entrez la chaine :");
 scanf("%s",mot);
 n=strlen(mot);
 rang=1;
 
 if (!(espace(mot[rang])))
  {printf ("1ere lettre doit etre vide : ERR1");  continue; }
   //getch();}
 else
 { rang++;
   vide=0;
   appG=0;
   etat2(mot,n,rang,vide,appG);
  // getch();
   if (vide)
      printf("Mot Vide : ERR2"); //getch();}
   else
       if (!appG)
	 printf("Pas alphabetique : ERR3"); //getch();}
       else
       {longueur=1;
	 motval=mot[rang];
	 rang++;
	 longmax=0;
	 blancs=0;
	 sortis=0;
	 appF=0;
	 etat3(mot,n,maxi,rang,longueur,longmax,blancs,sortis,appF);
 
	 if (sortis)
	   printf("Mot doit se terminer par espace: ERR4"); //getch();}
	  else
	   { if (longmax)
	       printf ("Vous avez depass‚ la long max : ERR5"); //getch();}
	     else
	     {	 if (!blancs)
		  printf("Caractere non autoris‚ : ERR6"); //getch();}
		  else
		  printf("LEXEME OK !!!"); //getch();}
	      }
	   }
	}
  }
}