Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- // before we could open a file and ONLY read it or ONLY write it
- // what if we want to change one users name? Don't want to write entire file over
- FILE * fPointer;
- // w+ open new file for writing first then reading
- fPointer = fopen("bacon.txt", "w+");
- fputs("I ate 3 pumpkins today", fPointer);
- // SEEK_SET means start at the beginning of the file
- fseek(fPointer, 7, SEEK_SET);
- fputs(" munchkins on Friday", fPointer);
- // SEEK_END means from the end of the file
- fseek(fPointer, -6, SEEK_END);
- fputs("top of a mountain", fPointer);
- fclose(fPointer);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement