Since this morning i try to find how to edit particular cells from a two dimensional array but i'm stuck by trying to make my code cleaner (Want to make functions and make them work together).
This is of course not my entire program but a piece of it (Simplified of course).
I got the following error On "char *TableauAfficher[][]" when i try to compile:
"error array type has incomplete element type"
#include <stdio.h>
#include <stdlib.h>
void AffTableau(int *i, int *j, char *TableauAfficher[][], int *LongLargMap) //ERROR
{
for (i=0; i<LongLargMap; i++) {
for(j=0; j<LongLargMap; j++) {
printf("Tableau[%d][%d] = %c\n", i, j, TableauAfficher[i][j]);
}
printf("\n");
}
int main()
{
int i, j;
int LongLargMap = 5;
char SaisieDirection;
int SaisieNombre;
char TableauAfficher[5][5];
int *Pointeuri = &i;
int *Pointeurj = &j;
int *PointeurLongLargMap = &LongLargMap;
char *PointeurTableauAfficher = &TableauAfficher;
TableauAfficher [0][0] = 'V';
TableauAfficher [0][1] = 'V';
TableauAfficher [0][2] = 'A';
TableauAfficher [0][3] = 'V';
TableauAfficher [0][4] = 'V';
TableauAfficher [1][0] = 'V';
TableauAfficher [1][1] = 'V';
TableauAfficher [1][2] = 'A';
TableauAfficher [1][3] = 'V';
TableauAfficher [1][4] = 'V';
AffTableau(Pointeuri, Pointeurj, PointeurTableauAfficher, PointeurLongLargMap);
}
iandjto function doesn't make any sense. You could declare those locally in funcition.int *LongLargMapto function serves no purpose. Passing by valueint LongLargMap, is faster and simpler.TableauAfficher, but in function you seem to try to read all rows. Reading uninitialized variables is undefined behaviour.