Skip to content
Sign upLog in
← Back to Community

Why cin isn't working?

Profile icon
Telewizorekhehe

"std::cin >> x;" and i have error, why?

Voters
Profile icon
Telewizorekhehe
Comments
hotnewtop
Profile icon
Coder100

you forgot to add a semicolon, here's the correct code:

#include <iostream> using namespace std; int main() { int a; cin >> a; }

perhaps your file didn't save so take some time for this to stop blinking:

image

Profile icon
JacobBirch

Put a semicolon at the end of line 6. The error message clearly says it expected a ; and it told you where.

Profile icon
Telewizorekhehe

@JacobBirch
I did this but this isn't working.

Profile icon
19ecal

You forgot the semicolon at the end of line 6 (which you would have known if you read the error message)

Profile icon
Telewizorekhehe

@19ecal
No, I didn't

Profile icon
19ecal

@Telewizorekhehe
Ok. When I answered your question, you had forgotten the semicolon at the end of line 6.
Now X is not defined. So, fix it by defining it, with something like std::string X; or int X;, depending on what type you want X to be.

Profile icon
Telewizorekhehe

@19ecal
This isn't working.

Profile icon
19ecal

@Telewizorekhehe
You forgot the semicolon at the end of line 6 (which you would have known if you read the error message)

Profile icon
Telewizorekhehe

@19ecal
I didn't

Profile icon
19ecal

@Telewizorekhehe

image

I am seeing a distinct lack of a semicolon

Profile icon
Telewizorekhehe

@19ecal
How is this possible????? Maybe this is repl.it bug?