-
-
Save parzibyte/64404cf5d882537836275d366d8f16bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#define NOMBRE_ARCHIVO "archivo.txt" | |
#define LONGITUD_MAXIMA_CADENA 1000 | |
int main(void) | |
{ | |
FILE *archivo = fopen(NOMBRE_ARCHIVO, "r"); // Modo lectura | |
char bufer[LONGITUD_MAXIMA_CADENA]; // Aquí vamos a ir almacenando cada línea | |
while (fgets(bufer, LONGITUD_MAXIMA_CADENA, archivo)) | |
{ | |
// Aquí, justo ahora, tenemos ya la línea. Le vamos a remover el salto | |
strtok(bufer, "\n"); | |
// La imprimimos, pero realmente podríamos hacer cualquier otra cosa | |
printf("La línea es: '%s'\n", bufer); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment