Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* File: newNames.c
- Saves names to file called names2.txt
- Author:
- Date Created:
- */
- #include<stdio.h>
- int main()
- {
- FILE *addNames;
- addNames = fopen("names2.txt", "w");
- fprintf(addNames, "Jason\n");
- fprintf(addNames, "Cesca\n");
- fprintf(addNames, "Stacey\n");
- fprintf(addNames, "Mckay\n");
- fclose(addNames);
- return 0;
- }
- // Read to a File
- #include<stdio.h>
- int main()
- {
- FILE *display;
- char name[100];
- display = fopen("names2.txt", "r");
- while(fgets(name, 100, display)!=NULL)
- {
- printf("%s", name);
- }
- fclose(display);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement