I just need to know how to solve my problem. The file is in french, but I will explain you.
Just test this code and enter :
3
Whatever String
Whatever String
Integer
Whatever String
Integer
Whatever String
Integer
Now you can see that the last two entry you entered are popping up two times, and I really don't understand why.
After to close, you can enter 'N' and 9.
I don't need you to judge my code, I know this is not the best way to do what I've done but it was the way needed for my homework. We are just in the beginning of learning C++.
I would say the problem is in line 96. Doing a while condition based on "eof" does not work the way you think it does. What you are seeing is that "eof" is reached inside the while loop, so when the input fails the last read is processed a second time before the while condition can check for "eof".
Generally the file read is done in the while condition, so that when the read fails the while loop fails. Without doing some translation it looks like the while condition would be while (fichierlecture>>string1>>string2) or at least while (fichierlecture>>string1). This way when you try to read past "eof" the while condition will fail.
Just for information line 130 in main while (ended == false) can be written as while (!ended). Both say the same thing and work the same. And the switch in main is easier to read when done like this:
switch (choix)
{
case 1:
RemplirTableau(tabchar, nblettre);
cout << "Il y a eu " << nblettre << " lettres de placees dans le tableau" << endl << endl;
break;
case 2:
AfficheTableau(tabchar, nblettre);
break;
case 3:
Recettes();
break;
case 9:
cout << "Fin du programme";
ended = true;
break;
default:
cout << "Choix Invalide" << endl << endl;
break;
}