GetChar en C

Fermé
Ju_ju_12 Messages postés 12 Date d'inscription samedi 1 janvier 2011 Statut Membre Dernière intervention 29 janvier 2011 - 29 janv. 2011 à 19:10
Bonjour!

Ma fonction getchar me renvoie un segmentation fault dans le contexte cidessous. (alors que c=getchar() avec c un char marche très bien ).
Est-ce que qqun voit d(ou vient le pb ?
Merci bien



/* Implémentation) du module read_item */

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "read_item.h"


enum type_item 	val;
char 			*F_op;
char* 			*F_id;
int 			*F_valint; 
float 			*F_valfloat;


enum type_item read_item(char *op, char **id, int *valint, float *valfloat) {
  char c;
  float vf,vf1;
  int vi;
  int i;
  char tab[50];
  do {

  c=getchar();
  
  putchar (c);
  
  } 

  while(c==' ' || c== '\t');
  
  if(isdigit(c)) {
    ungetc(c,stdin);
    scanf("%f",&vf);
    vi=vf;
    vf1=vi;
    if(vf1==vf) {
      *valint=vi;
      return entier;
    } 
    else { 
      *valfloat=vf;
      return flottant;
    }
  }
  else {
    switch(c) {
    case '\n': return eol;
    case '+':
    case '*':
    case '-':
    case '/':
    case '(':
    case ')': {
      *op=c;
      return operateur; }
    default :
      if(isalpha(c)) {
	i=0;
	do {
	  tab[i++]=c;
	  c=getchar();
	} while(isalpha(c));
	ungetc(c,stdin);
	tab[i]='\0';
	*id=strdup(tab);
	return ident;
      }
      else return error;
    }
  }
}



int main()
{
val = read_item(F_op, F_id, F_valint,F_valfloat);
return(0);

}