/* Exemplo de fgetc */ #include #include #include int main(void) { FILE *stream; char string[] = "Isto e um teste"; char ch; /* abre um arquivo para sobrescrever */ stream = fopen("DUMMY.FIL", "w+"); /* escreve um texto no arquivo */ fwrite(string, strlen(string), 1, stream); /* retorna ao inicio do arquivo */ fseek(stream, 0, SEEK_SET); do { /* le um caracter do arquivo */ ch = fgetc(stream); /* imprime o caracter lido */ putch(ch); } while (ch != EOF); fclose(stream); return 0; }