La meilleure solution est encore de sortir l'ami gdb:
[binarym@neotek]:~% cc -ggdb -lm -o linuxfr linuxfr.c 15:30
[binarym@neotek]:~% ulimit -c unlimited
[binarym@neotek]:~% ./linuxfr
zsh: segmentation fault (core dumped) ./linuxfr
[binarym@neotek]:~% gdb linuxfr core
GNU gdb 6.4.90-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/libthread_db.so.1".
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./linuxfr'.
Program terminated with signal 11, Segmentation fault.
#0 0xb7e40b5a in _IO_vfscanf () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7e40b5a in _IO_vfscanf () from /lib/tls/libc.so.6
#1 0xb7e40b11 in vfscanf () from /lib/tls/libc.so.6
#2 0xb7e4b1c2 in fscanf () from /lib/tls/libc.so.6
#3 0x080484c3 in main () at linuxfr.c:45
(gdb)
Donc ton segfault apparait dans ta fonction main, ligne 45, ce qui donne:
fscanf(f_in,"%f", &t[i]);
Si je me place dans cette frame pour regarder l'état des variables, ça n'a pas l'air d'être la fête:
(gdb) frame 3
#3 0x080484c3 in main () at linuxfr.c:45
45 fscanf(f_in,"%f", &t[i]);
(gdb) print f_in
1ドル = (FILE *) 0x0
(gdb) print i
2ドル = -1073881693
(gdb) print t
3ドル = {1.3997939922615464e-301, 8.289046058458095e-317, 3.946613931248307e+180,
2.0256691479491108e-322}
(gdb)
# Trouve le par toi meme ...
Posté par LaBienPensanceMaTuer . En réponse au message programme-"segmenattion fault". Évalué à 3.
[binarym@neotek]:~% cc -ggdb -lm -o linuxfr linuxfr.c 15:30
[binarym@neotek]:~% ulimit -c unlimited
[binarym@neotek]:~% ./linuxfr
zsh: segmentation fault (core dumped) ./linuxfr
[binarym@neotek]:~% gdb linuxfr core
GNU gdb 6.4.90-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/libthread_db.so.1".
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./linuxfr'.
Program terminated with signal 11, Segmentation fault.
#0 0xb7e40b5a in _IO_vfscanf () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7e40b5a in _IO_vfscanf () from /lib/tls/libc.so.6
#1 0xb7e40b11 in vfscanf () from /lib/tls/libc.so.6
#2 0xb7e4b1c2 in fscanf () from /lib/tls/libc.so.6
#3 0x080484c3 in main () at linuxfr.c:45
(gdb)
Donc ton segfault apparait dans ta fonction main, ligne 45, ce qui donne:
fscanf(f_in,"%f", &t[i]);
Si je me place dans cette frame pour regarder l'état des variables, ça n'a pas l'air d'être la fête:
(gdb) frame 3
#3 0x080484c3 in main () at linuxfr.c:45
45 fscanf(f_in,"%f", &t[i]);
(gdb) print f_in
1ドル = (FILE *) 0x0
(gdb) print i
2ドル = -1073881693
(gdb) print t
3ドル = {1.3997939922615464e-301, 8.289046058458095e-317, 3.946613931248307e+180,
2.0256691479491108e-322}
(gdb)
Je te laisse investiguer avec ces éléments ... :)