Hi!
I did a program that generates a random character and the user have to type the same character on the keyboard.
What i want to do is to use ARGC to define the number of characters that the program needs to generate one at once wich is 3 at my program.
The user must type the character after each one and not at the end of the tree characters.
Ex:
Output: t \\ Random character
t \\ Introduced by user
Output: g \\ Random character
d \\ Introduced by user
Output: s \\ Random character
s \\ Introduced by user
this is my code:
Code:
#include <stdio.h>
/**************************************
função generate_char()
**************************************/
static char first = 1; // Global variables
char x;
char generateChar() {
char caracter;
if (first) {
first = 0;
srandom(time(NULL));
}
x = random() % 26 + 'a';
printf("%c\n", x);
scanf("%c", &caracter);
if(caracter == x) {
printf("Equal");
}
else
printf("Not Equal");
}
main(int argc, char *argv[]) {
generateChar();
}
Thanks
Calavera