I am currently working on a password Validation program. It requires: at least 8 digits long, at lease 1 uppercase letter and 1 lowercase letter, and at least 1 number. The program will give the user only 3 tries. So I wrote the program. When I tested it, it says variable password has not been initialized. Could you please check what went wrong? It seems pretty ok to me... I need this to work ASAP! Thank you very much!
Your mistake is in reading the password. You can't use a char* like that, beacause you never allocate space for the word.
You could use char password[20]; with a maximum length or allocate the memory at run-time (dynamic allocation) or, maybe better, use a string and read with getline (since a password could also contain one or more spaces).
Good! Please bear in mind that in this way you are limiting the maximum length of the password. It could be ok but it could also be a mistake... It depends on whether you want to allow passwords longer than 20 characters or not. In case you want, the solution with a string would be much more flexible.