commit - 607c19eea8612833ca5e3125809f8821be427d49
commit + 0c5eba457ebda8944de67f7ecd6f82238a2a926a
blob - b587b957a2e87c436b60ffc39d809c7c79805cbf
blob + 10d874fa43a0b4ab7536d6127ad0dab48f0631bb
--- geomant.c
+++ geomant.c
# 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
{" ", " ", " ", " "}
} ;
-// 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
*/
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
}
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");
}
}
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();
printf (" \\_________________________________________/\n\n");
+ return 0;
}