alors voila mon fichier laby.c:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define longueur 15
#define largeur 10
void initialisation (void);
void liberer2d(int***,int);
int **allouer2d(int,int);
int main (void){
initialisation();
return 0;
}
void initialisation (void){
int k,i,j,nbcaseAzero,x,y,d;
int **laby;
laby=3Dallouer2d(longueur,largeur);
nbcaseAzero=3D1;
k=3D0;
for (i=3D0;i<longueur;i++){
for (j=3D0;j<largeur; j++){
if ((i%2!=3D0) && j%2!=3D0){
laby[i][j]=3Dk;
k=3Dk+1;
}
else laby[i][j]=3D-1;
}
}
while (nbcaseAzero<(longueur*largeur)){
x=3D(rand() % (longueur-2)+1);
y=3D(rand() % (largeur-2)+1);
while (laby[x][y]!=3D-1){
x=3D(rand() % (longueur-2)+1);
y=3D(rand() % (largeur-2)+1);}
if (i%2!=3D0){
d=3Dlaby[x][y-1]-laby[x][y+1];
if (d>0) {
laby[x][y]=3Dlaby[x][y+1];
/*fonction propager*/;
}
else if (d<0){
laby[x][y]=3Dlaby[x][y-1];
/*fonction propager*/;
}
}
else if (y%2!=3D0){
d=3Dlaby[x-1][y]-laby[x+1][y];
if (d>0) {
laby[x][y]=3Dlaby[x+1][y];
/*fonction propager*/;
}
else if (d<0){
laby[x][y]=3Dlaby[x-1][y];
/*fonction propager*/;
}
}
}
}
int **allouer2d(int l,int h){
int i, **t;
t=3Dmalloc(h*sizeof*t);
assert(t);
for (i=3D0;i<h;i++){
t[i]=3Dmalloc (l*sizeof*t[i]);
assert (t[i]);
}
return t;
}
void liberer2d(int*** q,int h){
int i;
for (i=3D0;i<h;i++)
free(*q);
*q=3DNULL;
}
alors lorsque je compile mon fichier avec gcc -Wall monfichier.c tous
ce passe bien.
Mais d=E9s que je lance le a.out j'ai Erreur de segmentation (core
dumped)
lorsque je lance gbd comme ce-ci: gdb ./a.out core
j'obtiens cela
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.
1".
warning: exec file is newer than core file.
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libc.so.6...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x0804858c in initialisation ()
(gdb)
quand je met en commande where j'obtiens cela
#0 0x0804858c in initialisation ()
#1 0x0804850b in initialisation ()
#2 0xb7e56ebc in __libc_start_main () from /lib/tls/i686/cmov/libc.so.
6
#3 0x08048391 in _start ()
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Eric Levenez
Le 25/05/07 21:08, dans , « Angelus » a écrit :
alors lorsque je compile mon fichier avec gcc -Wall monfichier.c tous ce passe bien.
Compile avec -g pour voir où se trouve le plantage.
Mais dés que je lance le a.out j'ai Erreur de segmentation (core dumped)
lorsque je lance gbd comme ce-ci: gdb ./a.out core j'obtiens cela GNU gdb 6.6-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i486-linux-gnu"... Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so. 1".
warning: exec file is newer than core file.
Pas normal ce warning
warning: Can't read pathname for load map: Input/output error. Reading symbols from /lib/tls/i686/cmov/libc.so.6...done. Loaded symbols for /lib/tls/i686/cmov/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 Core was generated by `./a.out'. Program terminated with signal 11, Segmentation fault. #0 0x0804858c in initialisation () (gdb)
Avec une compilation avec -g :
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 0x00002b98 in initialisation () at b.c:27 27 else laby[i][j]=-1; (gdb) print i $1 = 10 (gdb) print j $2 = 0
J'ai comme l'impression que tu as inversé ligne et colonne dans ton allocation.
-- Éric Lévénez -- <http://www.levenez.com/> Unix is not only an OS, it's a way of life.
Le 25/05/07 21:08, dans
<1180120100.273298.182760@q69g2000hsb.googlegroups.com>, « Angelus »
<shenneoron@gmail.com> a écrit :
alors lorsque je compile mon fichier avec gcc -Wall monfichier.c tous
ce passe bien.
Compile avec -g pour voir où se trouve le plantage.
Mais dés que je lance le a.out j'ai Erreur de segmentation (core
dumped)
lorsque je lance gbd comme ce-ci: gdb ./a.out core
j'obtiens cela
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.
1".
warning: exec file is newer than core file.
Pas normal ce warning
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libc.so.6...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x0804858c in initialisation ()
(gdb)
Avec une compilation avec -g :
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00002b98 in initialisation () at b.c:27
27 else laby[i][j]=-1;
(gdb) print i
$1 = 10
(gdb) print j
$2 = 0
J'ai comme l'impression que tu as inversé ligne et colonne dans ton
allocation.
--
Éric Lévénez -- <http://www.levenez.com/>
Unix is not only an OS, it's a way of life.
alors lorsque je compile mon fichier avec gcc -Wall monfichier.c tous ce passe bien.
Compile avec -g pour voir où se trouve le plantage.
Mais dés que je lance le a.out j'ai Erreur de segmentation (core dumped)
lorsque je lance gbd comme ce-ci: gdb ./a.out core j'obtiens cela GNU gdb 6.6-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i486-linux-gnu"... Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so. 1".
warning: exec file is newer than core file.
Pas normal ce warning
warning: Can't read pathname for load map: Input/output error. Reading symbols from /lib/tls/i686/cmov/libc.so.6...done. Loaded symbols for /lib/tls/i686/cmov/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 Core was generated by `./a.out'. Program terminated with signal 11, Segmentation fault. #0 0x0804858c in initialisation () (gdb)
Avec une compilation avec -g :
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 0x00002b98 in initialisation () at b.c:27 27 else laby[i][j]=-1; (gdb) print i $1 = 10 (gdb) print j $2 = 0
J'ai comme l'impression que tu as inversé ligne et colonne dans ton allocation.
-- Éric Lévénez -- <http://www.levenez.com/> Unix is not only an OS, it's a way of life.
Angelus
merci beaucoup , effectivement j'avais inverser les lignes et colonnes de mon allocation , maintenant sa marche ^^
merci beaucoup , effectivement j'avais inverser les lignes et colonnes
de mon allocation , maintenant sa marche ^^