0
Help :
2 Answers
+ 1
#include <iostream>
using namespace std;
int main() {
char x[8];
cout << "Put a Password with 8 letters/numbers" << endl;
// x = Password
for (int i = 0; i <= 7; i ++){
cin >> x[i];
}
cout << x;
if (isdigit(x)){
cout << "Your Password isn't really safe. It includes just numbers." ;
// Doesn't matter if just numbers, just an information
}
if (!isdigit(x)){
cout << "Success: Password has been created"; << endl;
}
return 0;
}
what is the problem ?
always error : something like
unvalid change of char* to int
0
I think the problem is the argument u pass to isdigit. U pass an array of char to isdigit, but isdigit need an int as argument (the code ASCII of the char).
So, the second part of the code should be like this (after "cout<<x")
i=0; //set i to 0 again for the next loop
bool justNumbers=true; //a variable that tells u if one of the char isn't a number.
while (i <=7)
{
if (!isdigit(x [i]))
{
justNumbers=false; //if isdigit returns false...
}
i++;
}
if (justNumbers==true)
{
cout << "your password is not safe........";
}
return 0;
}
I don't know if this work. If u don't understand anything (or the code doesn't work) just tell me.
Bye!