+ 1

Help me!

Help me! What is the problem in this code? ____________________ #include <iostream> #include <conio.h> using namespace std; Int main() { char username; char password; cout << " user name :" ; cin << username; cout << " password:" ; cin << password; getch() ; return 0; } __________________________ I run it, when I want to enter password, when I press a key, the app finishes! My IDE is Code blocks

10th Jan 2019, 1:48 PM
Taha Lahooti
Taha Lahooti - avatar
2 Respuestas
+ 3
cin>> not cin<< And if you write 'char password', 'password' can hold only 1 char. Your code must be like this: #include <iostream> #include <conio.h> using namespace std; Int main() { char username[100]; char password[100]; //can hold up to 100 char or you can use 'string username' instead👍 cout << " user name :" ; cin >> username; cout << " password:" ; cin >> password; getch() ; return 0; }
10th Jan 2019, 2:13 PM
LetterC67
LetterC67 - avatar
+ 2
Thanks my firiend😋
11th Jan 2019, 8:20 AM
Taha Lahooti
Taha Lahooti - avatar