Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /*
- * File: main.c
- * Author: NgT
- *
- * Created on February 22, 2016, 10:16 AM
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- //#define TRUE 1;
- //#define FALSE 0;
- /*
- *
- */
- void WriteFile(char* pFileName, char* pContent) {
- int length = 0;
- FILE* f = fopen(pFileName, "a");
- fflush(stdin);
- do {
- gets(pContent);
- length = strlen(pContent);
- if (length > 0) {
- fputs(pContent, f);
- }
- } while (length > 0);
- fclose(f);
- }
- void ReadFile(char* pFileName) {
- char c;
- FILE* f = fopen(pFileName, "r");
- while ((c = fgetc(f)) != EOF)
- putchar(c);
- fclose(f);
- }
- int main() {
- char filename[10], content[100];
- printf("Enter file to save content: ");
- gets(filename);
- printf("Enter content: ");
- gets(content);
- WriteFile(filename, content);
- printf("File content : \n");
- ReadFile(filename);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement