Can someone help me please find the ploblem with this program ? I know it's a question of a misssing pointer but i don't know where to put it ..
#include<stdio.h>
void remplissage_matrix(char M[50][50],int l , int c);
void remplissage_elements(int l, int c ,char M[50][50],char elements[100],int *n);
void remplissage_histo(int histo[100],char elements[100],int *n);
int main()
{
int l,c,n,m ;
char M[50][50],elements[100];
int histo[100];
printf("Saisir le nombre des lignes de la matrice \n");
scanf("%d",&l);
printf("Saisir le nombre des colonnes de la matrice \n");
scanf("%d",&c);
remplissage_matrix( M, l , c);
remplissage_elements(l,c,M,elements,&m);
remplissage_histo( histo,elements,&m);
return 0 ;
}
void remplissage_matrix(char M[50][50],int l , int c)
{
int i,j,k,x=0,n;
for (i=0;i<l;i++)
{
for (j=0;j<c;j++)
{
printf("Saisir M[%d][%d]",i,j);
fflush(stdin);
scanf("%c",&M[i][j]);
}}
for (i=0;i<l;i++)
{
for (j=0;j<c;j++)
printf("M[%d,%d]= %c \n" ,i,j,M[i][j]);
}
}
void remplissage_elements(int l, int c ,char M[50][50] ,char elements[100],int *n)
{
int i,j,k,x;
for (i=0;i<l;i++)
{
for(j=0;j<c;j++)
{
elements[x++]= M[i][j];
}
}
*n= l * c;
for(i=0; i < *n; i++)
{
for(j=i+1; j < *n; )
{
if(elements[j] == elements[i])
{
for(k=j; k < *n;k++)
{
elements[k] = elements[k+1];
}
*n--;
}
else {
j++;
}
}
}
for(i=0; i < *n; i++)
{
printf("Elements[%d] est %c \n",i, elements[i]);
}
}
void remplissage_histo(int histo[100],char elements[100], int *n)
{
int i,j,x,count;
for(i = 0; i < *n; i++) {
count = 1;
for(j = i+1; j < *n; j++) {
if(elements[i]==elements[j]) {
histo[j] = 0;
count++;
}
}
if(histo[i]!=0) {
histo[i] = count;
}
}
for(i = 0; i<*n; i++) {
if(histo[i] != 0) {
printf("Element %c : Count %d\n", elements[i], histo[i]);
}
}
for(x = 0; x < *n; x++)
{
if( histo[x] > 0){
printf("%c",&elements[x]);
for(i = 1; i <= histo[x]; ++i){
printf("*");
}
printf("\n");
}
}
}