Pablo:

Si tu único interés es convertir un archivo de
registros fijos, con la forma (todo en una sola linea)

00000100JUAN CARLOS GARCIA           
2010111000000110JOSE MIGUEL LOPEZ            
2011111300000130JUAN JOSE GONZALEZ           
2013411000000200LUIS ARTURO PEREZ            
2018671000000455PABLO JOSE GARCIA             21101112

a 

00000100JUAN CARLOS GARCIA            20101110
00000110JOSE MIGUEL LOPEZ             20111113
00000130JUAN JOSE GONZALEZ            20134110
00000200LUIS ARTURO PEREZ             20186710
00000455PABLO JOSE GARCIA             21101112

esto te puede servir

#include <stdio.h>
#include <malloc.h>
/**
 * Lee un archivo de registros de ancho fijo y lo 
 * convierte a lineas
 * @todo leer como parametro el nombre del archivo
 * @todo controlar que exista
 * @todo controlar el malloc()
 * @todo leer como parametro la longitud del registro
 */
int main(int argc, char ** argv) {
        FILE * fd = fopen("alumnos.dat","r");
        void * line =malloc(46);
        size_t size;
        while ( (size = fread(line, 46 , 1, fd))) {
                printf("%s\n",(char *)line);
        }
        fclose(fd);
        free(line);
}



tras compilar ejecuta ./a.out > alumnos.txt

Carlos


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
Lista de correo Programacion.
[email protected]
http://listas.fi.uba.ar/mailman/listinfo/programacion

Responder a