help

hello everyone!
i'm new in studying c++ and i'm a bit geting confused :(
#include<iostream>
#include<istream>
using namespace std;
int main()
{
int b;
cout << "enter b value:";
cin >> b;
cout << "the value of b is:" << b;
return(getchar());
}
why doesn't it execute??
Last edited on
This program works for me.
enter b value:5
the value of b is:5
@Gyova , compiler is not same .

maybe we using same compiler .
and Kindly use code tag . it's look messy

change your

return(getchar());

to
return 0;
maybe you're using older compilies...
i looked in the previous archieves related problems and tried "cin.get(); 2times" and it worked.could someone explain the reason of using this statement 2 times? ,
and thank you everyone for the reply,i'll appreciate ur concern
@chipp ,
actually yes. i think it is old version but i do not know(my bad) how to update it
afaik, the first is to extract stream from buffer, the 2nd for waiting the user's input ('\n')

CMIIW
Thank you @chipp
Topic archived. No new replies allowed.