#include <stdio.h>
#include <stdlib.h>

#define MAX_WRONG_CNT 6

int main( void )
{

#if 1

	//****************************************************//
	// Example for Dynamic Memory Allocation of Word List //
	// ***************************************************//
	
    
    // get word count

    int wordCount;
    printf("Please enter the word count: ");
    scanf("%d", &wordCount);
    
    // make memory for word list
    // 		how to make an array of type X with size N:
    // 			X *p = malloc( N * sizeof(X) )
    char ** wordList = (char **) malloc(wordCount * sizeof(char*));

    
    // get words from the user
    for( int i=0; i < wordCount; i++) {

        printf("Please enter %d th word: ", i+1);

		// allocate a 20-byte memory block for each word
        wordList[i] = (char *)malloc(20);

        scanf("%s", wordList[i]);
        
    }
    
	// display stored words
    for(int i=0; i<wordCount; i++) {
        printf("The word is %s\n", wordList[i]);
    }
    
    
#endif
    
	//**************************************//
	// Example for Random Number Generation //
	// *************************************//
	
	// display maximum value of rand()
	printf("RAND_MAX: %d\n", RAND_MAX );

	// get current time
	time_t t;
	time(&t);
	printf("Current Unix Time/Epoch Time: %d\n", t);

	// set random seed
	srand( t );

	// print three random numbers
	printf("a randome number: %d\n", rand() );
	printf("a randome number: %d\n", rand() );
	printf("a randome number: %d\n", rand() );
    
	printf("A randomly chosen word is %s\n", wordList[ rand() % wordCount ] );

	system("pause");

	return 0;
}
