Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- //files allow you to save data even when you shut off your computer
- //sequential access files - must write your data in order
- //random access files - can store data all over
- //need this to keep track of where you are in your file
- FILE * fPointer;
- //now we need to open a file to point to
- //w - write (aka create) a new file
- //r - read from a file
- //a - append (aka add on to) end of existing file
- fPointer = fopen("bacon.txt", "w");
- fprintf(fPointer, "I love cheese\n");
- //if you run this again, it will overwrite the old file
- fclose(fPointer);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement