Created
March 16, 2013 12:42
-
-
Save mertsimsek/5176217 to your computer and use it in GitHub Desktop.
Read and Write on File in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void readInput(char* inputFile) { | |
FILE *fp; | |
fp = fopen(inputFile, "r"); | |
int x; | |
while ((x = fgetc(fp)) != EOF) { | |
printf("%c", x); | |
} | |
fclose(fp); | |
} | |
void writeOutput(char* outputFile, char* text) { | |
FILE *p = NULL; | |
size_t len = 0; | |
p = fopen(outputFile, "w"); | |
if (p == NULL ) { | |
printf("Error in opening a file.."); | |
} | |
len = strlen(text); | |
fwrite(text, len, 1, p); | |
fclose(p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment