I'm currently trying to work out some issues I am experiencing with this code, can't really figure out why I am getting these 2 errors. I tried to see if something was not closed, but this not does seem to be the case, can be be cause of the distance between the ": "? I'm just grasping for straws by now..
main.cpp:30:38: error: expected ‘;’ before ‘generationString’
cout << "Generation " << x << ": " generationString << endl;
main.cpp:54:40: error: expected ‘;’ before ‘generationString’
cout << "Generation " << x++ << ": " generationString << endl;
When trying to compile this code:
#include <iostream>
using namespace std;
string
initString ()
{
}
int
calculateScore (string guess, string target)
{
}
string
mutate (string mutationString)
{
}
int
main ()
{
string targetString = "METHINKS IT IS LIKE A WEASEL";
string generationString = initString ();
string currentString = generationString;
int score = calculateScore (currentString, targetString);
int x = 0;
cout << "Generation " << x << ": " generationString << endl;
do
{
for (int i = 0; i < 100; i++)
{
string newCopy = generationString;
newCopy = mutate (newCopy);
int copyScore = calculateScore (newCopy, targetString);
if (copyScore > score)
{
currentString = newCopy;
score = copyScore;
if (copyScore == targetString.length ())
{
break;
}
}
}
generationString = currentString;
}
while (score < targetString.length ());
cout << "Generation " << x++ << ": " generationString << endl;
return 0;
}