Excuse me.. How can I get a string chain and then beak it up to check letter by letter?
Here you have a sample of my code:
What am I doing wrong?Code:#include <stdio.h> #include <iostream.h> #include <string.h> #include <stdlib.h> main() { /* int CharSize; int i; CharSize = 3; char CadChar[3]; int Estado;*/ int CharSize; int i; int Estado; char *CadChar; cout<<"Automata Finito"<<endl<<endl; cout<<"Dame una palabra: "; cin>>CadChar; cout<<endl; cout<<CadChar; CharSize = strlen(CadChar); /* for(i=1; i <= CharSize; i++){ cout<<"Dame una letra: "; cin>>CadChar[i]; cout<<endl; }*/ for(i=0; i < CharSize; i++){ cout<<CadChar[i]; } Estado = 0; for(i=0; i < CharSize; i++){ if(CadChar[i] == 'a'){ Estado = 0; } else{ if(CadChar[i] == 'b' && Estado < 2){ Estado++; } } } if(Estado == 2){ cout<<"La cadena es valida"<<endl; } else{ cout<<"La cadena es invalida"<<endl; } char a; cout<<endl<<endl<<"Presione cualquier tecla para terminar..."; cin>>a; return 0; }




Rest in Peace, we will take care of the rest of it.
Reply With Quote