its it skipping. This is the part of the code. :(

cout<<"enter a string\n";
getline(std::cin,phrase);

#include <iostream>
#include <string>
#include "phrase.h"
#include "EA.h"
#include <cstdlib>
#include <time.h>

int main()
{
	phrase a;
	EA b;
	std::string phrase;
	int populationsize;
	//int percentmutation;
	std::cout<<"enter a population size\n";
	std::cin>>populationsize;
	b.setpopulationsize(populationsize);
	//std::cout<<"enter the percentage you would like to mutate\n";
	//std::cin>>percentmutation;
	std::cout<<"enter a string\n";
	getline(std::cin,phrase);
	
	//std::cout<<a.getphraselength();

	srand ((unsigned)time(0));
	
	
	b.initalizepopulation();
	/*while(phrase!=bestofpopulation())
	{
		//mutate and crossover to create new population
	}*/
	
	return 0;
}

Put in a cin.ignore() after line 16 and before line 21. Your excess '\n' from when you enter the integer remains in the stream and gets caught by the getline. getline figures it has a line and stops reading.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.