Bonsoir,

Je suis entrain de coder un shell basique, j'ai un bug lors de la compilation:

gcc -O -pipe -g3 -W -Wall -pedantic -ansi -c my_epur.c
my_epur.c: In function `list_full_args_tab':
my_epur.c:26: error: request for member `cmd' in something not a structure or union
my_epur.c: In function `list_malloc_args_tab':
my_epur.c:41: error: request for member `cmd' in something not a structure or union
my_epur.c:41: error: request for member `cmd' in something not a structure or union
my_epur.c:46: error: request for member `cmd' in something not a structure or union
my_epur.c:46: error: request for member `cmd' in something not a structure or union
my_epur.c:47: error: request for member `cmd' in something not a structure or union
my_epur.c:51: error: request for member `cmd' in something not a structure or union
*** Error code 1


J'essaie de malloc le char **cmd du maillon de ma liste (t_data *new) de la taille du char **args de ma structure, et de copier l'un dans l'autre:

fichier.h
Code : 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
typedef struct s_path
{
  char          *path;
  int           i;
  int           y;
  int           debut;
  int           fin;
}               t_path;
 
typedef struct s_args
{
  int           nb_read;
  int           len;
  char          **args;
}               t_args;
 
typedef struct  s_data
{
  char          **cmd;
  struct s_data *next;
}               t_data;
Ici j'appel mes fonctions
Code : 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
void            ordon_data(t_data **list, t_args *ptr)
{
  t_data        *moove;
  t_data        *new;

  new = malloc(sizeof(*new));
  new->next = NULL;
  list_malloc_args_tab(&new, ptr->args, ptr->len);
  list_full_args_tab(&new, ptr->args);
  if (*list == NULL)
    *list = new;
  else if (*list != NULL)
    {
      moove = *list;
      while (moove != NULL)
        moove = moove->next;
      moove = new;
    }
}
Ici je tente de malloc et de copier
Code : 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
void            list_full_args_tab(t_data **new, char **args)
{
  int           y;
  int           x;

  y = 0;
  x = 0;
  while (args[y])
    {
      while (args[y][x])
        {
          (*new->cmd)[y][x] = args[y][x];
          x++;
        }
      y++;
      x = 0;
    }
}

void            list_malloc_args_tab(t_data **new, char **args, int len)
{
  int           x;
  int           y;

  x = 0;
  y = 0;
  (*new->cmd) = malloc((len + 1) * sizeof(*(*new->cmd)));
  while (args[y])
    {
      while (args[y][x])
        x++;
      (*new->cmd)[y] = malloc((x + 1) * sizeof(*(**new->cmd)));
      (*new->cmd)[y][x + 1] = '\0';
      y++;
      x = 0;
    }
  (*new->cmd)[y] = NULL;
}
Merci de me donner un petit coup de main !