[prev] [index] [next]

The FILE* Type (cont)

Common operations on FILE* objects:

int fgetc(FILE *inf) ... read next character (cast to an int) from inf

int fputc(int ch, FILE *outf) ... write ch to outf

char *fgets(char *buf, int size, FILE *inf);

  • read chars from inf into buf; stop at \n or after size chars
int fputs(char *buf, FILE *outf);
  • write all chars from buf to outf
int fclose(FILE *fp);
  • flushes any buffered output to fp and then closes fp