Ver Mensaje Individual
  #5 (permalink)  
Antiguo 23/11/2009, 08:35
vrael
 
Fecha de Ingreso: mayo-2007
Mensajes: 200
Antigüedad: 17 años, 9 meses
Puntos: 1
Respuesta: Problema con tildes en archivos

No me termina de funcionar. Me dan numeros raros, y salen comas ( , ) donde no deberían salir.

Dejo el código que tengo para ver si sabes cual es el problema:

Código:
#include <stdio.h>
int main(void)
{
    int salir;
    Leer();
    printf("Todo ha ido bien");
    scanf("%d", &salir);
    return 0;
}

int Leer()
{    
    int numero, tiempo, salir;
    char categoria[400], objetivo[1000], descripcion[1000];
	char line[80];
    FILE* fichero;
    
    fichero=fopen("bateria.txt", "r"); 

	if (fichero == NULL)
	{
		printf("No se puede abrir el fichero\n");
		return 0;
	}
	else
	{
		while ( !feof(fichero) )
		{
            fgets(line, sizeof(line), fichero);
                sscanf(line, "%d", &numero);
                fgets(categoria, sizeof(categoria), fichero);
                fgets(objetivo, sizeof(objetivo), fichero);
                fgets(descripcion, sizeof(tiempo), fichero);
                fgets(line, sizeof(line), fichero);
                sscanf(line, "%d", &tiempo);
	        printf("%d, \n%s, \n%s, \n%s,\n %d\n", numero, categoria, objetivo, descripcion, tiempo);
        }
    }
	close(fichero);
	return numero;
}