#include "stdafx.h"
#include <iostream>



using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	char ch;
	
	do{
		cout<<"press Q or q to quit,press any key to continue  :  ";
		cin.get(ch);
		cin.ignore();
		
		if(ch!='Q'&&ch!='q')
			cout<<" you want to continue?\n";

		else
			cout<<"you press q to quit ";
		
		
	}while(ch!='Q'&&ch!='q');
	;

	system("pause>NULL");
	return 0;
}

my prof said that whenever how many the letter i input the output must be just one..
output
press any key to continue : ma.teresa l. sagun
you want to continue?
press any key to continue :
you want to continue?
press any key to continue :
you want to continue?
press any key to continue :
you want to continue?
press any key to continue :
you want to continue?
press any key to continue :
you want to continue?
press any key to continue :

it appears like this..will someone help me..

Recommended Answers

All 5 Replies

you must provide CLEAR details if you want people to help you, what exactly is suppose your code to do?

commented: . +7

Looks like the ch.get(ch) takes each of your input character in and execute them one by one. As a result, each character is being checked in the loop.

Flush the input stream after input...

while (cin.get (temp) && temp != '\n');

fflush(stdin) will help you!
from: <snipped link>

post your question on <link removed>, computer experts will answer your question quickly.

hi, guys
have you solved your problem?

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.