+ 4

Why isn't this code working ?

Constructive criticism is accepted. This code isn't working does anyone have an explanation. I ran the code in Code::Blocks #include <iostream> using namespace std; void crappyPrint() { signed int x; cin >> "What is your name ? " >> x >> endl; } int main() { cout << "Your name is "; crappyPrint(); return 0; } If you want the build log, Just ask :)

20th Mar 2017, 2:28 AM
ΞⓀ⒟Ⓝ⒌Ξ
ΞⓀ⒟Ⓝ⒌Ξ - avatar
6 Answers
+ 15
cin is solely used for console input, and has to be followed by a variable. You should do it this way: cout << "What is your name?" << endl; cin >> x; // P.S. Burn Code::Blocks.
20th Mar 2017, 2:42 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
@Hasty Rei i love code::block == 😑lol
20th Mar 2017, 9:40 AM
Leon lit
Leon lit - avatar
+ 2
@Hasty Rei thank you anyway
20th Mar 2017, 9:18 PM
ΞⓀ⒟Ⓝ⒌Ξ
ΞⓀ⒟Ⓝ⒌Ξ - avatar
+ 1
@Hasty Rei I thought so but I saw something like that somewhere else(Eclipse)
20th Mar 2017, 12:44 PM
ΞⓀ⒟Ⓝ⒌Ξ
ΞⓀ⒟Ⓝ⒌Ξ - avatar
+ 1
Don't forget to use char array or string for Name variable
21st Mar 2017, 11:57 AM
Azizbek Kobilov
Azizbek Kobilov - avatar
0
:0 it should be char x[ ], you cannot take alphabets in a numerical variable...and you have to take an array as well...
21st Mar 2017, 3:21 PM
Uwais Khan
Uwais Khan - avatar