struct marco{
  char letra;
  bool estado;
  char vec[4];
  char palabra1[4];
  bool spal1[4] = {0};
  char palabra2[4];
  bool spal2[4] = {0};
}churrito[2];

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println(anagram("hola","o la"));
  Serial.println(anagram("hola","hola"));
  Serial.println(anagram("hola","halo"));


}

void loop() {
/*churrito[0].estado = 1;
churrito[1].estado = 0;
churrito[2].estado = 0;
churrito[3].estado = 1;

for(int i = 0; i < 4; i++){
  Serial.println(churrito[i].letra);
}

delay(1000);*/

}

void guardar (const char* a, const char* b) {
  
  for(int i=0;i<sizeof(a);i++){
    churrito[0].palabra1[i]=a[i];
  }
  for(int i=0;i<sizeof(b);i++){
    churrito[0].palabra2[i]=b[i];
  }

}


bool anagram (const char* a, const char* b){
  int sum =0;
  if(sizeof(a) == sizeof(b)){
    guardar(a,b);
    uint8_t contador=0;
    uint8_t j = 0, i = 0;
//    Serial.println(churrito[0].spal1[i]);
    while( j != sizeof(a)){
        Serial.println(j);
        if(!churrito[0].spal1[i]){
          if(churrito[0].palabra1[i] == churrito[0].palabra2[j] && churrito[0].spal2[j]==false){
            churrito[0].spal1[i]=true;
            churrito[0].spal2[j]=true;
            j=0;
            i++;
            
          }
          else{
            j++;

          }
        }
      sum++;
    }
    Serial.println("El valor de i es:");
    Serial.println(i);
    
    /*for(uint8_t i=0; i<sizeof(b); i++){
      for(uint8_t j=0+contador; j<sizeof(b); j++){
        if(churrito[0].palabra1[i] == churrito[0].palabra2[j]){
          contador++;
          break;
        }
      }
    }*/
    
    for (int k = 0; k < sizeof(churrito[0].spal1); k++){
      if(!churrito[0].spal1[k]){
        Serial.print("hola");
        Serial.println(k);
        return false;
      } 
    }
    return true;
  }
  else{
    return false;
  }
}

//marco.letra = 'a';
Loading
esp32-s2-devkitm-1