getchar()

thE cOde is wOrking weLL the prObLem is with that getchar() user input it is nOt taking input frOm the usEr.......the cOde is weLL working with cin,getch() && getche() bt nOt with getchar().....:(
here iss the prOg cOde.....


#include<iostream>
#include<conio.h> //header file incLuded tO include get character getch()
#define pi 3.1415926 //to definE the vaLue of a cOnstAnt pi
using namespace std;
float circum(float); //prOtotypE
main()
{

float rad;
char tr; // character tr fOr getting char 'y' if u wAnt tO caLcuLatE othEr chaLLan


do
{
system("cls"); //cLears the scrEEn.....:D
cout<<"plz give thE rAdius fOr caLcuLating circumfErenc : ";
cin>>rad;
cout<<"thE circumfErncE of circL = "<<circum(rad);//functOn caLL
cout<<endl;
cout<<"u wAnt tO calcuLate circumfErencE agAin(y/n)";
//cin>>tr; //use cin tO prOmpt usEr or getch() or getche()
//tr =getch(); //do not show the character enterd
//tr =getche(); //dispLay the character
tr =getchar(); //enter the char untiL entEr is prEsed nOt wOrking right nOw
cout<<"\n";
}
while(tr == 'y');

system("pause");
}



float circum(float rad) //functiOn definAtOn
{

return(2*pi*rad);

}
Please use code tags, and what's with the random capitals ? That makes it hard to read, and makes you look like a troll.
Topic archived. No new replies allowed.