Skip to content

Instantly share code, notes, and snippets.

@CaaioSB
Last active June 11, 2020 21:20
Show Gist options
  • Save CaaioSB/27544d04d4713e942728bc34f51d92e7 to your computer and use it in GitHub Desktop.
Save CaaioSB/27544d04d4713e942728bc34f51d92e7 to your computer and use it in GitHub Desktop.
Análise e Desenvolvimento de Sistemas: Atividade em C - 1º Semestre
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
int contador = 0;
char linha[64];
FILE *fp;
fp = fopen("arquivo.txt", "r");
if (fp != NULL)
{
while (!feof(fp)){
fgets(linha, 64, fp);
if (!feof(fp)){
contador++;
printf("%i - %s", contador, linha);
}
}
}
else{
printf("Arquivo inválido.");
}
system("pause > nul");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment