|
|
Files - Reading and Writing |
|
Once the file has been opened various methods exist for reading and writing from it.
int getc (FILE* fp)
Return the next character from the FILE. Return EOF for end of file or an error.
int putc (int c, FILE* fp)
Write the given character to the FILE. Return the character written or EOF if there's an error.
int fscanf(FILE *fp, char *format, ...)
Identical to scanf except that it takes a file pointer as the first argument.
int fprintf(FILE* fp, char* format, ...)
Identical to printf except that it takes a file pointer as the first argument.
char* fgets(char* line, int maxlen, FILE* fp)
Read the next input line, including the newline from fp into line; at most maxlen - 1 characters will be read. Return line on success or EOF on error.
int fputs(char* line, FILE* fp)
Write the contents of line to fp. Return 0 on success and EOF on error.