I can't make the function mostrarmatriz() work. The program does compile and run from beginning to end without errors, but the function mostrarmatriz() doesn't show up anything. When I copy that function into the main function it works perfectly. It seems I'm having a problem passing the values by reference. Please help, I'm stuck.
Main.c File:
#include "InvMatriz.h"
#include <stdio.h>
int main(int argc, char **argv)
{
float **A;
int n;
printf("Ingrese el tamaño de la matriz: ");
scanf("%d", &n);
A = ingresematriz(n);
void mostrarmatriz(A, n);
printf("adfasd");
return 0;
}
Header File InvMatriz.h
#ifndef INVMATRIZ_H_
#define INVMATRIZ_H_
float** ingresematriz(int );
void mostrarmatriz(float**X ,int x);
#endif // INVMATRIZ_H
Ingrese Matriz.c File
#include "InvMatriz.h"
#include <stdio.h>
float **ingresematriz(int n)
{
int i, j;
//Asigna espacio en la memoria
float **A;
A = malloc(n * sizeof (float *));
for (i = 0; i < n; i++)
{
*(A + i) = malloc(n * sizeof(float));
}
//Pide los elementos y los guarda
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
printf("Elemento [%d] [%d]: ", i + 1, j + 1);
scanf("%f", *(A + i) + j);
}
}
return A;
}
Mostrar Matriz.c File
#include "InvMatriz.h"
#include <stdio.h>
void mostrarmatriz(float **X , int x) //Porque no hace nada pero si compila?
{
int i, j;
for (i = 0; i < x; i++)
{
for (j = 0; j < x; j++)
{
printf("%f ", *(*(X + i) + j));
}
printf("\n");
}
}