std :: string :: find renvoie toujours string :: npos même s'il est supposé trouver quelque chose. Dans ce cas, j'essaie de trouver un {suivi d'une nouvelle ligne. Mais peu importe la corde que je mets là, elle ne le trouvera pas.std :: string :: find toujours retourne string :: npos even
pos=0;
while(pos!=string::npos)
{
ko=input.find("{\n"); //here is the problem!!!
if(ko!=string::npos && input[ko]=='\n')
{
input.erase(ko, 3);
kc=input.find("}", ko);
for(pos=input.find("\",", ko); pos<kc; pos=input.find("\",\n", pos))
{
input.erase(pos, 4);
input.insert(pos, " | ");
}
pos=input.find("\"\n", ko);
input.erase(pos, 3);
}
else
{
break;
}
}
pos=0;
cn=1;
for(pos=input.find("\"", pos); pos!=string::npos; pos=input.find("\"", pos))
{
input.erase(pos,1);
if(cn)
{
input.insert(pos,"R");
}
cn=1-cn;
}
Voici un morceau de ce que l'entrée a:
-- declaring identifiers of state and final states
Detecting_SIDS = {
"Detecting",
"Detecting_CleanAir",
"Detecting_GasPresent"
}
-- declaring identifiers of transitions
Detecting_TIDS = {
"__NULLTRANSITION__",
"Detecting_t2",
"Detecting_t3",
"Detecting_t4",
"Detecting_t5"
}
Ce code est censé tourner cette entrée ci-dessus pour les éléments suivants:
-- declaring identifiers of state and final states
datatype Detecting_SIDS = RDetecting | RDetecting_CleanAir | RDetecting_GasPresent
-- declaring identifiers of transitions
datatype Detecting_TIDS = RNT | RDetecting_t2 | RDetecting_t3 | RDetecting_t4 | RDetecting_t5
Si elle trouve quelque chose, 'entrée [ko]' sera égal '{', 'pas \ n'. Vous lui donnez une condition toujours fausse. – krzaq
Assomption on doit toujours être "j'ai probablement fait quelque chose de mal". Et en effet vous l'avez fait. Lisez ce que renvoie 'std :: find'. –
Oops, && input [ko] == '\ n' était le coupable. Je mets au débogage et oublie de l'enlever. Merci @krzaq –