HI.
Does somebody know how to put a char # in every character we type.
I think that it is with Systems Calls.
Example: The program gives me a random character.
Then i have to type the same character, but it haves to appears
´#´.
Code:
#include <stdio.h>
/**************************************
função generateChar()
retorna uma letra minúscula aleatória
**************************************/
char x;
char generateChar() {
static char first = 1;
if (first) {
first = 0;
srandom(time(NULL));
}
x = random()%26+'a';
return x;
}
int main(int argc, char *argv[]) {
char caracter;
if(argc < 2) { //Verifica o numero de argumentos passados
printf("FALTAM ARGUMENTOS\n");
exit(1);
}
int valor = atoi(argv[1]); // transforma o argv[1] em inteiro
int i;
for(i = 0;i<valor;i++) { // Ciclo que imprime o caracter aleatorio o numero de vezes passado a argv[1]
printf("%c\n",generateChar());
do {
scanf(" %c",&caracter); // Le o caracter dado pelo utlizador
if(caracter != x) { // Verifica se é igual ao aleatorio
printf("TENTE DE NOVO\n");
}
}
while(caracter != x); // enquanto o caracter introduzido fôr diferente do aleatorio continua a pedir
}
printf("Letra\t\tTempo de Resposta\t\tInstante da resposta\n");
printf("%c\t\t\t\t\t\t%s%s\n", x, __DATE__":",__TIME__);
}
If i insert ´a´, it haves to appear ´#´, but must read ´a´, the output of the letters must be always a '#' like a password but the program must save the letter and not the '#'.
Thanks