Bonjour à tous. Voila, nouveau dans la programmation en C, je tombe souvent sur des erreurs de segmentation. Pourtant je n'en vois pas la cause. Quelqu'un pourrait-il me donner des indices ? Merci beaucoup !


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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
#include <stdlib.h>
#include <stdio.h>
#define MAX 20
 
typedef struct Point Point;
struct Point
{
  int   num;
  int   x;
  int   y;
};
 
void    affiche_info(Point*);
 
int     main(int argc, char **argv)
{
  char  res;
  int   i;
  Point tabPoint[MAX];
 
  i = 0;
  do
    {
      printf("Entrez les informations concernant le point nouvellement créé \
: \n");
      printf("\tNuméro : %d\n", i+1);
      (tabPoint+i)->num = i+1;
      printf("\tPosition en x : ");
      scanf("%d", (tabPoint+i)->x);
      printf("\tPosition en y : ");
      scanf("%d", (tabPoint+i)->y);
      printf("Voulez vous enregistrer un nouveau point ? (y/n)");
      scanf("%c", &res);
      i++;
    }
  while (res == 'y' && i<MAX);
 
  printf("Retournement des informations : \n");
  affiche_info(tabPoint);
 
  return 0;
}
 
void    affiche_info(Point *tab)
{
  int   i;
 
  i = 0;
  while (i<MAX)
    {
      printf("Numéro du point : %d\n", tab[i].num);
      printf("Position en x : %d\n", tab[i].x);
      printf("Position en y : %d\n", tab[i].y);
      i++;
    }
}
Le segment fault arrive apres la saisi de la coordonnée en x du premier point créé. Merci beaucoup pour votre aide.