-
-
Save parzibyte/2034c5a3a5cb3375cf23ada75370ab31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void leerContrasenaSinMostrarla(char *palabraSecretaDestino) | |
{ | |
int caracterLeido = 0; | |
char temporal[2]; | |
while (caracterLeido != TECLA_ENTER) | |
{ | |
limpiarPantalla(); | |
printf("Ingresa tu palabra secreta: "); | |
enmascaraCadena(palabraSecretaDestino, strlen(palabraSecretaDestino), MASCARA); | |
caracterLeido = getch(); | |
// https://parzibyte.me/blog/2019/11/02/c-char-a-string/ | |
temporal[0] = caracterLeido; | |
temporal[1] = '\0'; | |
if (caracterLeido == TECLA_BORRAR) | |
{ | |
if (strlen(palabraSecretaDestino) > 0) | |
{ | |
// https://parzibyte.me/blog/2022/03/23/eliminar-ultimo-caracter-cadena-c/ | |
palabraSecretaDestino[strlen(palabraSecretaDestino) - 1] = '\0'; | |
} | |
} | |
else if (caracterLeido != TECLA_ENTER) | |
{ | |
strncat(palabraSecretaDestino, temporal, 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment