Basic c++ "what wrong" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Basic c++ "what wrong"

compilation error #include <iostream> using namespace std; int main() { int a; int b; cin>> a >>endl; cin>> b >>endl; cout<<a<<endl; cout<<b; return 0; }

6th Feb 2017, 2:46 PM
Yuriy az
Yuriy az - avatar
4 Answers
+ 16
Don't use "endl" with cin, doesn't work. And write it like this: cin>>a>>b;
6th Feb 2017, 2:59 PM
Filip
Filip - avatar
+ 14
No problem
6th Feb 2017, 3:08 PM
Filip
Filip - avatar
+ 1
Thx that was the problem 😘
6th Feb 2017, 3:02 PM
Yuriy az
Yuriy az - avatar
+ 1
endl is a defined value. But not variable. it shouldn't be placed at cin << when you enter an integer into console. And press the "Enter" key. The buffer will be flushed to cin. endl is not necessary.
6th Feb 2017, 3:09 PM
K.C. Leung
K.C. Leung - avatar