Commit 6d4850d6 authored by João Denis Rodrigues's avatar João Denis Rodrigues

adiciona codigo de arquivo

parent 5f8ec801
/* O programa que le arquivos e exibe-os na tela */
#include <stdio.h>
#include <stdlib.h>
void main (int argc, char *argv[]) {
FILE *fp;
char ch;
if (argc != 2) {
printf ("Voce esqueceu de informar o nome do arquivo!\n");
exit (1);
}
if ((fp = fopen(argv[1], "r")) == NULL) {
printf ("O arquivo nao pode ser aberto\n");
exit (1);
}
ch = getc(fp); /* le um caractere */
while (ch != EOF) {
/* repete enquanto nao for o final do arquivo */
printf("%c", ch); /* imprime caracter lido na tela */
ch = getc(fp); /* le proximo caracter */
}
fclose(fp); /*fecha o arquivo */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment