Start New Discussion within our Software Development Community

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

cout<<"enter a string\n";

#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::cout<<"enter the percentage you would like to mutate\n";
	std::cout<<"enter a string\n";

	srand ((unsigned)time(0));
		//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.

This question has already been answered. Start a new discussion instead.