Commit Diff


commit - 607c19eea8612833ca5e3125809f8821be427d49
commit + 0c5eba457ebda8944de67f7ecd6f82238a2a926a
blob - b587b957a2e87c436b60ffc39d809c7c79805cbf
blob + 10d874fa43a0b4ab7536d6127ad0dab48f0631bb
--- geomant.c
+++ geomant.c
@@ -10,18 +10,10 @@
 # include <string.h>
 # include <unistd.h>
 
-int mantize ( int n_bodypart, int n_figure ) ;
-int generate() ;
-int main() ;
+int mantize(int, int);
+int generate();
+int main();
 
-char *txt_topic ; size_t txt_topic_size = 0UL ;
-
-// arrays displaying which figure part the user is generating.
-// used between the mantize() function that gathers/parses  user input,
-// and generate() that generates the figures from it.
-static char *mother_figures[] = { "1st", "2nd", "3rd", "4th" } ; int n_figure ;
-static char *body_parts[] = { "head", "neck", "body", "feet" } ; int n_bodypart ;
-
 // figures initialization (all 15 figures)
 char *figures[15][4] = {
 	// mothers
@@ -48,10 +40,6 @@ char *figures[15][4] = {
 	{"   ", "   ", "   ", "   "}
 } ;
 
-// used to temporarily store user input, which may be anything other than \0 and \n
-char *txt_raw_scrap = NULL ;
-size_t txt_raw_scrap_size = 0UL ;
-
 /*
  *    "mantize" : input fuction
  * This function gathers a string of user input
@@ -62,8 +50,7 @@ size_t txt_raw_scrap_size = 0UL ;
  */
 
 int mantize ( int n_bodypart, int n_figure ) {
-	printf ( "Hold or repeatedly press a key or keys to generate the %s of the %s mother, then press Enter:\n",
-		body_parts[n_bodypart], mother_figures[n_figure] ) ;
+	char *txt_raw_scrap = NULL ; size_t txt_raw_scrap_size = 0UL ; // storing user input
 	getline ( &txt_raw_scrap, &txt_raw_scrap_size, stdin ) ; 
 	return ( ( strlen ( txt_raw_scrap ) -1 ) % 2 ) ; // substracting 1 as the \n character
 }
@@ -79,11 +66,15 @@ int mantize ( int n_bodypart, int n_figure ) {
 int generate(){
 	
 	// generating the mothers
+	char *mother_figures[] = { "1st", "2nd", "3rd", "4th" } ; int n_figure ;
+	char *body_parts[] = { "head", "neck", "body", "feet" } ; int n_bodypart ;
 	for ( n_figure = 0 ; n_figure < 4 ; n_figure++ ) {
 		for ( n_bodypart = 0 ; n_bodypart < 4 ; n_bodypart++ ) {
+			printf ( "Hold or repeatedly press a key or keys to generate the %s of the %s mother, then press Enter:\n",
+				body_parts[n_bodypart], mother_figures[n_figure] ) ;
 			figures[n_figure][n_bodypart] =
 			(0 == mantize(n_bodypart, n_figure)) ? "* *" : " * " ;
-			system("clear");
+			//system("clear");
 		}
 	}
 
@@ -164,6 +155,7 @@ int generate(){
 int main(){
 	
 	printf("What is the subject title of your enquiry ?\n");
+	char *txt_topic = malloc ( 0UL ) ; size_t txt_topic_size = 0UL ;
 	getline ( &txt_topic, &txt_topic_size, stdin ) ; 
 	
 	generate();
@@ -210,4 +202,5 @@ int main(){
 	
 	printf ("  \\_________________________________________/\n\n");
 	
+	return 0;
 }