Bonjour
J'ai un problème avec le message d'erreur "bus error" quand je tente d'executer ce bout de programme. Il n'y a pourtant aucune erreur de compilation (cc -Wall -Wextra -O2 exotp2.c -o out) .

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
58
59
60
61
62
63
64
65
66
67
68
#include<stdio.h>
#include<stdlib.h>
 
typedef float  vect[20];
 
void lire (vect x,vect y, int *n);
float lag(vect x, vect y, int n, float al);
 
 
void lire (vect x,vect y, int *n)
{
	int i;
	float * a;
	float * b;
 FILE *F;
F=fopen("exo2.txt","r");
i = 0;
while(!feof(F))
{
 
	fscanf(F,"%f;%f",a,b);
	fscanf(F,"%f;%f",x[i],y[i]);
 
	i=i+1;
	printf("Lecture ...");
}
  *n=i-1;
 
fclose(F);
}
 
 
float lag(vect x, vect y, int n, float al)
{
float p=0.,l;
int i,j;
 
 
 
for(i=0;i<n;i++)
{
	l=1.;
	for(j=0;j<n;j++)
	{
		l=l*(al-x[j])/(x[i]-x[j]);
	}
	p=p+(l*y[i]);
}
 
 
 
return p  ;
}
 
 
int main (void)
{
	int * n =NULL;
	vect x ,y;
	float P,al=-1.5;
 
lire(x,y,n);
 
P=lag(x,y,*n,al);
 printf("la valeur de p(%f) est: %f\n",al,P);
 
return 0;
}