Problème dans l'exécution d'un prog en c++

Fermé
midouray Messages postés 4 Date d'inscription samedi 7 décembre 2013 Statut Membre Dernière intervention 17 décembre 2013 - 17 déc. 2013 à 21:05
Bonjour,

je voeux réaliser un programme c++ pour identifier une requête SQL et ainsi savoir dans la requête les identificateur, les mots clefs ou les nombres
voici mon programme :

#include<stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
  char ch[1000],unit[1000] ; 
  int i,c,j;
  
  char sep[8]={'(',')','|','*','{','}','[',']'};
  char mot[10][100]={"create","table","insert","into","value","select","all","distinct","from","where"};
  char op[7]={'+','-','*','/','<','>','='};
  printf("entrer une requete SQL \n");
  scanf("%s",&ch);
 
  i=0;
  unit[i]=' ';
  if (isalpha(ch[i]))c=0;
  if (isdigit(ch[i]))c=1;
  printf ("%d \n",c);
  printf ("%s",ch);
  printf ("%d \n",i);
  for(j=0;j<8;j++)
  {
     if(ch[i]==sep[j]) c=2;
  }
  for (j=0;j<7;j++)
  {
      if (ch[i]==op[j])c=3;
  }
  
        while(i<strlen(ch))
                           {
                           switch(c)
                           {
                                case 0:
                                {
                                   while (ch[i]!=' ')
                                   {   
                                   unit[i]=unit[i]+ch[i];
                                   i++;
                                   }
                                   
                                   unit[i]= ch[i];
                                    printf ("%s \n",unit);
                                     printf ("%s \n",ch);
                                 
                              
                                     
                                      if (unit[i]==*mot[j])
                                      printf("unit est mot clé \n");   
                                      else 
                                      printf("unit est un identificateur \n "); 
                                      
                                      
                                }break;
                 
                                case 1:
                                  {
                                   while (ch[i]!=' ')
                                    {
                                     unit[i]=unit[i]+ch[i];
                                     i++;
                                    }
                                    printf("unit est un nombre \n");
                                
                                  }    break;             
                                case 2:
                                  {
                                   while (ch[i]!=' ')
                                    {
                                     i++;
                                    
                                    unit[i]==sep[j] ;
                                    }
                                    printf("unit est un separateur \n");
           
                                  }break;  
                                case 3:
                                  { 
                                   while (ch[i]!=' ')
                                       {
                                        i++;
                                        
                                        unit[i]==op[j];
                                        }
                                        printf("unit est un operateur \n");
                                         
                                   }  break;            




 
                                 default: if(isspace(ch[i])) 
                                          {
                                           i++;
  
                                            } 
}
 }
 getch();
 }