Bonsoir à tous,
j'ai (encore) un petit problème avec une fonction qui doit lire un tableau de char* et formater avec sscanf pour stocker les bons coefficients dans une matrice. voici le code (j'ai simplifié pour faire apparaitre juste l'érreur de segmentation)

Code c : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
/*
*NOTE:
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NBL 10
#define NBC 3
/*
*  Reads data from a file
*  @param nom_fichier: the file's name
*  @return the file content in a char*
*/
int** alloc_tab_2_D(int nbre_lig, int nbre_col);
int main(int argc, char *argv[]){
char *var = "10 3\n1 2 3\n4 5 6\n7 8 9\n 1 2 3\n4 5 6\n7 8 9\n1 2 3\n4 5 6\n7 8 9\n1 2 3";
 int i, j;
 int **tab_2_d = alloc_tab_2_D(NBL, NBC);
 int current_offset = 5;
    for( i = 0; i < NBL; i++)
    {
        for(j = 0; j < NBC; j++)
        {
            //La valeur à recuperer se trouve toujours à un indice paire, les indices impaires sont les espaces et les \n
            /*CONTENT EX:3 3\n1 2 3\n4 5 6\n7 8 9\0
              INDICES EX:012_3456789.............*/
 
            sscanf(&var[current_offset], "%d", &tab_2_d[i][j]);
            printf("|%d, i= %d j= %d OFF = %d\n", tab_2_d[i][j], i, j, current_offset);
 
            current_offset +=2;//skip spaces and /n
 
        }
    }
}
int** alloc_tab_2_D(int nbre_lig, int nbre_col){
    int i=0,j=0;
    int** tab_2_d = (int**)malloc(nbre_lig * sizeof(int));
    for(i = 0; i < nbre_lig; i++)
    {
        tab_2_d[i] = (int*)malloc(nbre_col * sizeof(int));	
    }
 
    return tab_2_d; 
}

Mais à chaque fois j'obtiens une erreur de segmentation quand l'indice i vaut 5 et j vaut 2 !. Quelqu'un peut -il m'aider?