Type |
Application |
Example |
Notes |
FILE* 's
fopen
fclose
|
before you can interact with a file, you need to create a connection or stream |
 |
- save the connection
- open the file
- call the
fopen function
- send in the filename string
- send in the mode string (double quotes, not single!)
"r" is read
"w" is write
"a" is append
- verify the connection is made
- check the
FILE pointer for the NULL pointer
- if it's the
NULL pointer, quit
- CAUTION! If the
FILE pointer is NULL , you will get a segmentation fault if you use it.
- close the connection (after interacting with the file)
|
fprintf |
outputs text to a stream |
 |
- this looks just like Formatted IO, but with the
FILE pointer as the first argument
- you can use still things like field width and precision to format how your output looks
|
fscanf |
gets input text from a stream |
 |
- this looks just like Formatted IO, but with the
FILE pointer as the first argument
|
fgets |
gets input text as a C-Style String from a stream |
 |
- this looks just like Formatted IO with C-Style Strings, but with the
FILE pointer as the last argument
|