-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclave.cpp
More file actions
35 lines (28 loc) · 713 Bytes
/
clave.cpp
File metadata and controls
35 lines (28 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ===================================================================================
Programa: Leer clave ---- by mark TM
//El programa necesita estas bibliotecas
#include <conio.h>
#include <stdio.h>
#include <windows.h>
//Definir ENTER
#define ENTER 13
La funcion : leerClave("Titulo",max,variable);
=================================================================================== */
void leer_clave(char *titulo, int maxCaracteres, char *clave){
printf("%s: ",titulo);
char c;
int i = 0;
while((c = getch()) != ENTER && i < maxCaracteres-1){
if(c == 8){
if(i > 0){
i--;
printf("\b \b");
}
} else {
printf("*");
clave[i] = c;
i++;
}
}
clave[i] = '\0';
}