Tema: fgets
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/02/2008, 06:20
drbit
 
Fecha de Ingreso: mayo-2006
Mensajes: 120
Antigüedad: 18 años, 10 meses
Puntos: 3
Re: fgets

No veo ningún error en tu código, lo probé y lee el fichero perfecto.

Código:
#include <stdio.h>
#include <string.h>

int main() {

  FILE *f;
  char *froot; 
  char *root;
  char controot[255];
  char nombre[255];

  root="root.txt";

  strcpy(nombre, root);

  f = fopen(nombre, "r");

  if (f == NULL)
    {
      printf("Error al tratar de abrir el archivo %s",nombre);
      return 1;
    }
  else
    {
      printf("Abre root");
    }

  froot=fgets(controot,100,f);
  printf("\nTras leer root, contenido froot: %s y controot: %s \n", froot, controot);//controot);
  froot=fgets(controot,100,f);
  printf("\nTras leer root2, contenido froot: %s y controot: %s \n", froot, controot);
  return 0;
}
__________________
programación php