May 25, 2010 at 12:25pm UTC
hi
in this code loop executes more time time loop, it is something wrong with the cin.get(ch) function call(i mean i dont know it works). can someone help with this. thank you.
#include <iostream>
void failas();
void nustatymai();
void isspauzdinti();
void klaida();
void rodyti_meniu();
using namespace std;
int main()
{
char ch;
rodyti_meniu();
cin.get(ch);
while (ch!='q')
{
switch (ch)
{
case 'a': failas();
break;
case 'b': nustatymai();
break;
case 'c': isspauzdinti();
break;
default : klaida();
}
rodyti_meniu();
cin.get(ch); //there is something wrong, while with cin>>ch there is no,,
}
return 0;
}
void failas()
{
cout<<"\nSiuo metu neimanoma to padaryti..\n";
}
void nustatymai()
{
cout<<"\nSiuo metu neimanoma to padaryti..\n";
}
void isspauzdinti()
{
cout<<"\nSiuo metu neimanoma to padaryti..\n";
}
void klaida()
{
cout<<"\nPrasome ivesti atitinkama simboli.\n";
}
void rodyti_meniu()
{
cout<<"######################\n"
<<"\nMeniu Prasome pasirinkti :\n"
<<"a.File..\tb.Nustatymai..\n"
<<"c.Isspauzdinti..\n";
}
May 25, 2010 at 12:28pm UTC
I think you to need move cin.get() to loop while and if I am write you can change from while to do ... while()(it helps to remove redundant code)
Last edited on May 25, 2010 at 12:28pm UTC