commit 35d6920fea1783d110a4c39d03407c8d5c3b8989
parent 2e62fde61b3edc338398b8fd5402ab474944c3a9
Author: klewer-martin <martin.cachari@gmail.com>
Date: Mon, 26 Apr 2021 22:23:55 -0300
Update;
Diffstat:
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/main.c b/main.c
@@ -8,31 +8,20 @@
int main (void)
{
- /*
- matrix_t matrix;
- m_load_dim(&matrix);
-
- m_create(matrix.rows, matrix.columns, &matrix);
-
- m_initrand(&matrix);
- m_print(&matrix);
- putchar('\n');
-
- m_destroy(&matrix);
- */
status_t st;
static matrix_t **matrix_ids;
/* Only prints the main header */
prompt_welcome();
+ /* array to store the matrix entered on the program execution */
matrix_ids = (matrix_t **)calloc(MATRIX_IDS_ARRAY_LENGTH, sizeof(matrix_t));
for(size_t i = 0; i < MATRIX_IDS_ARRAY_LENGTH; i++)
matrix_ids[i] = (matrix_t *)calloc(MATRIX_ID_MAX_LENGTH, sizeof(matrix_t));
/* The main prompt ask for a matrix interactively and returns a pointer to it with the values already initialized */
for(size_t i = 0;i < UINT_MAX;i++) {
- if((st = get_matrix(matrix_ids[i])) != OK) {
+ if((st = get_matrix(matrix_ids[i], matrix_ids)) != OK) {
/* Prompt what do you want to do with the matrix you entered? */
printf("%s", "What do you want to do with the matrix you entered?: ");
return st;
diff --git a/prompt.c b/prompt.c
@@ -19,7 +19,7 @@ status_t user_input(user_input_t option)
return OK;
}
-status_t get_matrix(matrix_t *matrix)
+status_t get_matrix(matrix_t *matrix, matrix_t **matrix_ids)
{
printf("1.- Load a matrix's values of dimensions N x M by hand.\n2.- Load a matrix's values with a .txt file.\n3.- Create a random matrix of dimensions N x M.\nq - exit\n\nWhat do you want to do?: ");
char *buffer;
@@ -51,7 +51,7 @@ status_t get_matrix(matrix_t *matrix)
case 1:
{
/* Enter the matrix Number(1 .. 128, Default 1): */
- printf("%s", "Enter the matrix Number (1 .. 128, Default 1): ");
+ printf("%s", "Enter the matrix id number (1 .. 128, Default 1): ");
fgets(buffer, DIM_BUFFER_MAX_SIZE, stdin);
if(buffer[0] == '\n') {
diff --git a/prompt.h b/prompt.h
@@ -17,7 +17,7 @@ typedef enum {
void prompt_welcome(void);
status_t user_input(user_input_t option);
-status_t get_matrix(matrix_t *matrix);
+status_t get_matrix(matrix_t *matrix, matrix_t **matrix_ids);
status_t matrix_menu_prompt(void);
status_t load_m_hand(matrix_t *matrix);