DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Ejemplo De Lectura De Archivo Secuencial
// description of your code here
#include <stdio.h>
void main()
{
FILE *ptr;
char nombre[15],c;
int ok, edad;
ptr = fopen("datos.txt", "r");
do
{
ok = fscanf(ptr, "%d %s", &edad, nombre);
if (ok)
printf("Edad: %d\n Nombre:%s\n", edad, nombre); /* despliega en pantalla */
else
printf("*****Error en la lecura");
}
while (!feof(ptr)); /* Se repite hasta encontrar EOF (ctrl + z) */
fclose(ptr);
printf("pulse una tecla para continuar");
scanf("%c", &c);
}




