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

	char filename[64];

	if (inv[1] == NULL) {
		strcpy(response, "User did not select a file for input");       // Error check if user did not select a file
	}
	else {
		strcpy(filename, inv[1]);

		int i;
		FILE* dump;
		dump = fopen(filename, "w");

		if (dump == NULL) {
			strcpy(response, "Error unable to create file");                                        // Error check for when the program cannot fopen
		}
		else {
			knowledge_write(dump);                                                                  // Save the knowledge base using the knowledge_write function in knowledge.c
			snprintf(response, n, "My knowledge has been saved to %s.", filename);        // Output message to user to let them know that the file has been saved
		}
		fclose(dump);
	}
	return 0;
}
/*
 * Save the chatbot's knowledge to a file.
 *
 * See the comment at the top of the file for a description of how this
 * function is used.
 *
 * Returns:
 *   0 (the chatbot always continues chatting after saving knowledge)
 */
Save the chatbot's knowledge to a file.

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

0 (the chatbot always continues chatting after saving knowledge)
Save the chatbot ' s knowledge to a file . See the comment at the top of the file for a description of how this function is used . 0 ( the chatbot always continues chatting after saving knowledge )
int chatbot_do_save(int inc, char* inv[], char* response, int n) {
	char filename[64];
	if (inv[1] == NULL) {
		strcpy(response, "User did not select a file for input");       
	}
	else {
		strcpy(filename, inv[1]);
		int i;
		FILE* dump;
		dump = fopen(filename, "w");
		if (dump == NULL) {
			strcpy(response, "Error unable to create file");                                        
		}
		else {
			knowledge_write(dump);                                                                  
			snprintf(response, n, "My knowledge has been saved to %s.", filename);        
		}
		fclose(dump);
	}
	return 0;
}
int chatbot_do_save ( int inc , char * inv [ ] , char * response , int n ) { char filename [ 64 ] ; if ( inv [ 1 ] == NULL ) { strcpy ( response , " " ) ; } else { strcpy ( filename , inv [ 1 ] ) ; int i ; FILE * dump ; dump = fopen ( filename , " " ) ; if ( dump == NULL ) { strcpy ( response , " " ) ; } else { knowledge_write ( dump ) ; snprintf ( response , n , " " , filename ) ; } fclose ( dump ) ; } return 0 ; }
Save the chatbot's knowledge to a file.
Save the chatbot ' s knowledge to a file .
// Error check if user did not select a file
 // Error check for when the program cannot fopen
 // Save the knowledge base using the knowledge_write function in knowledge.c
 // Output message to user to let them know that the file has been saved
