c-project/C Project/C Project/chatbot.c
int chatbot_do_smalltalk(int inc, char* inv[], char* response, int n) {
	time_t t;

	for (int i = 0; i < MAX_REPLIES; i++) {
		if (compare_token(inv[0], USER_GREETINGS[i]) == 0) {
			srand((unsigned)time(&t));                                                          // Initialise a random number generator
			int rng = rand() % MAX_REPLIES;                                                     // Gets a ramdom number between and MAX_REPLIES
			sprintf(response, "%s", CHATBOT_GREETINGS[rng]);                                    // Print out the response from the bot
		}
		else if (strncmp(inv[0], "it's", 4) == 0 || strncmp(inv[0], "It's", 4) == 0) {          // Check the user input for the predefined keyword "it's" or "It's". Somehow compare_token hates It's
			snprintf(response, n, "Indeed it is.");                                             // Print out the proper response from the bot
			return 0;
		}
	}
	return 0;
}
/*
 * Respond to smalltalk.
 *
 * See the comment at the top of the file for a description of how this
 * function is used.
 *
 * Returns:
 *   0, if the chatbot should continue chatting
 *   1, if the chatbot should stop chatting (e.g. the smalltalk was "goodbye" etc.)
 */
Respond to smalltalk.

See the comment at the top of the file for a description of how this
function is used.

0, if the chatbot should continue chatting
1, if the chatbot should stop chatting
Respond to smalltalk . See the comment at the top of the file for a description of how this function is used . 0 if the chatbot should continue chatting 1 if the chatbot should stop chatting
int chatbot_do_smalltalk(int inc, char* inv[], char* response, int n) {
	time_t t;
	for (int i = 0; i < MAX_REPLIES; i++) {
		if (compare_token(inv[0], USER_GREETINGS[i]) == 0) {
			srand((unsigned)time(&t));                                                          
			int rng = rand() % MAX_REPLIES;                                                     
			sprintf(response, "%s", CHATBOT_GREETINGS[rng]);                                    
		}
		else if (strncmp(inv[0], "it's", 4) == 0 || strncmp(inv[0], "It's", 4) == 0) {          
			snprintf(response, n, "Indeed it is.");                                             
			return 0;
		}
	}
	return 0;
}
int chatbot_do_smalltalk ( int inc , char * inv [ ] , char * response , int n ) { time_t t ; for ( int i = 0 ; i < MAX_REPLIES ; i ++ ) { if ( compare_token ( inv [ 0 ] , USER_GREETINGS [ i ] ) == 0 ) { srand ( ( unsigned ) time ( & t ) ) ; int rng = rand ( ) % MAX_REPLIES ; sprintf ( response , " " , CHATBOT_GREETINGS [ rng ] ) ; } else if ( strncmp ( inv [ 0 ] , " " , 4 ) == 0 || strncmp ( inv [ 0 ] , " " , 4 ) == 0 ) { snprintf ( response , n , " " ) ; return 0 ; } } return 0 ; }
Respond to smalltalk.
Respond to smalltalk .
// Initialise a random number generator
 // Gets a ramdom number between and MAX_REPLIES
 // Print out the response from the bot
 // Check the user input for the predefined keyword "it's" or "It's". Somehow compare_token hates It's
 // Print out the proper response from the bot
