+ 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
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;
}
+ 2
Thanks my firiend😋