cout<<"Enter the first string:";
		string first_string;		
		getline(cin,first_string);	
		
		cout<<"Enter the second string:";
		string second_string;		
		getline(cin,second_string);

when the code is as above the there is nothing read through the strings.

cout<<"Enter the first string:";
		string first_string;
		getline(cin,first_string);
		getline(cin,first_string);
		
		
		cout<<"Enter the second string:";
		string second_string;		
		getline(cin,second_string);
		getline(cin,second_string);

however, if the code is as shown above they are read but it is needed to press the enter twice.

i am confused. why does not it read from keyboard when the first code is executed?

Your first program worked correctly for me using vc++ 2008 express.

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.