IPB

Bienvenue invité ( Connexion | Inscription )

> Bus Error en C, Sous OS X dans le terminal
Options
mackintosh
posté 4 Oct 2006, 22:16
Message #1


Adepte de Macbidouille
*

Groupe : Membres
Messages : 121
Inscrit : 2 Jan 2003
Lieu : Moselle - Metz
Membre no 5 405



Bonsoir,

j'utilise depuis peu mon imac pour compiler des sources C pour différents tp ...
les exemples de base, boucles etc ... marchent très bien mais je rencontre un souci avec un petit programme qui est sensé lire puis restituer un fichier sur l'ecran du shell

J'obtiens le message suivant : Bus error ....
voici ci dessous la source du programme, si quelqu'un pourrait m'éclairer un peu sur ce problème ?

CODE
#include <stdio.h>
int main()
{
FILE *f;
char c;
char saisie;

printf("saisissez le fichier a lire");

scanf("%c", &saisie);
f=fopen("saisie", "r");


while (! feof(f))
{
c=fgetc(f);
printf("%c", c);
}


}



"lecture.c" 21L, 211C


Ce message a été modifié par mackintosh - 4 Oct 2006, 22:17.


--------------------
Rien ne sert de courir si l'on est pas sur le bon chemin.
Go to the top of the page
 
+Quote Post

Les messages de ce sujet
- mackintosh   Bus Error en C   4 Oct 2006, 22:16
- - Cochonou   Salut, à vue d'oeil, tu alloues des char (c e...   4 Oct 2006, 22:20
- - schlum   Yeah ! Buffer overflow Le truc qui est ador...   4 Oct 2006, 22:27
- - mackintosh   un Bus Error correspondrait donc à un BufferOverf...   4 Oct 2006, 22:32
- - Cochonou   Normalement, quand tu accèdes à une zone mémoir...   4 Oct 2006, 23:04
- - mackintosh   J'ai testé les solutions, à priori c'est...   5 Oct 2006, 16:20
- - mpergand   http://www.lri.fr/~aze/page_c/aide_c/scanf.html   5 Oct 2006, 16:28
- - schlum   1 - scanf %c c'est pour récupérer 1 caractè...   5 Oct 2006, 17:09
- - mackintosh   En effet çà fait pas mal de choses qui peuvent p...   5 Oct 2006, 17:31
- - Doom Hammer   Le programme crash (probablement sur feof ou fgetc...   5 Oct 2006, 17:38
- - Cochonou   Doom Hammer a certainement raison, parce qu'un...   5 Oct 2006, 21:23
- - mackintosh   au final c'était tout simplement un problème...   6 Oct 2006, 20:35
|- - schlum   CITATION(mackintosh @ 6 Oct 2006, 21:35) ...   6 Oct 2006, 20:54
- - franklinchef   Petite rectification pour tout le monde: Bus erro...   9 Oct 2006, 21:12
|- - noop   CITATION(franklinchef @ 9 Oct 2006, 22:12...   10 Oct 2006, 10:07
||- - franklinchef   CITATION(noop @ 10 Oct 2006, 05:07) 19256...   10 Oct 2006, 13:42
||- - noop   CITATION(franklinchef @ 10 Oct 2006, 14:4...   10 Oct 2006, 13:49
||- - franklinchef   CITATION(noop @ 10 Oct 2006, 08:49) 19259...   10 Oct 2006, 14:43
||- - noop   CITATION(franklinchef @ 10 Oct 2006, 15:4...   10 Oct 2006, 14:54
||- - chombier   CITATION(noop @ 10 Oct 2006, 15:54) 19259...   10 Oct 2006, 16:01
||- - noop   CITATION(chombier @ 10 Oct 2006, 17:01) 1...   10 Oct 2006, 16:09
||- - chombier   CITATION(noop @ 10 Oct 2006, 17:09) 19261...   10 Oct 2006, 16:32
||- - noop   CITATION(chombier @ 10 Oct 2006, 17:32) 1...   11 Oct 2006, 09:14
||- - chombier   CITATION(noop @ 11 Oct 2006, 10:14) 19270...   11 Oct 2006, 09:48
||- - noop   CITATION(chombier @ 11 Oct 2006, 10:48) 1...   11 Oct 2006, 10:29
|- - mackintosh   CITATION(franklinchef @ 9 Oct 2006, 22:12...   12 Oct 2006, 19:01
|- - chombier   CITATION(mackintosh @ 12 Oct 2006, 20:01)...   12 Oct 2006, 19:20
- - schlum   Vous exagérez quand même Dans les sources de ...   11 Oct 2006, 10:44
- - chombier   Et ? emacs est sensé être LA référence en mati...   11 Oct 2006, 10:46
|- - noop   CITATION(chombier @ 11 Oct 2006, 11:46) 1...   11 Oct 2006, 11:09
|- - mpergand   CITATION(noop @ 11 Oct 2006, 12:09) 19272...   11 Oct 2006, 13:10
- - schlum   Avec "kmalloc", il vaut mieux (sinon c...   11 Oct 2006, 10:55
|- - chombier   CITATION(schlum @ 11 Oct 2006, 11:55) 192...   11 Oct 2006, 11:15
- - Cochonou   CITATION a moins que tu sois dans un environnement...   12 Oct 2006, 12:26
|- - Fotz   CITATION(Cochonou @ 12 Oct 2006, 13:26) 1...   12 Oct 2006, 12:40
|- - noop   CITATION(Fotz @ 12 Oct 2006, 13:40) 19289...   12 Oct 2006, 12:52
- - mackintosh   Je vois que le sujet a suscité beaucoup de réact...   12 Oct 2006, 15:40
|- - noop   CITATION(mackintosh @ 12 Oct 2006, 16:40)...   12 Oct 2006, 15:45
- - schlum   CODESECURITY CONSIDERATIONS The gets() f...   12 Oct 2006, 19:21
- - mackintosh   D'accord je comprends mieux maintenant ! m...   12 Oct 2006, 19:30


Reply to this topicStart new topic
2 utilisateur(s) sur ce sujet (2 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Nous sommes le : 3rd April 2026 - 15:20