Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- // Gera senha aleatoria
- // Autor Alexandre Campos
- // Gera 1 numero aleatorio ate um limite
- int numero_aleatorio(int maximo)
- {
- return random() % maximo;
- }
- char gera_char_aleatorio()
- {
- // Retorna aleatorio entre a e a+26 (sao 26 letras)
- return 'a' + numero_aleatorio(26);
- }
- int main()
- {
- // Chamar 1 vez
- srand(time(NULL));
- for (int i=0; i<100; i++)
- {
- char resultado = gera_char_aleatorio();
- int codigo = resultado;
- printf("Char: %c\n", resultado);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement