-
-
Save webgtx/1f49d4fad395334d3b7897dfd25a9f3b to your computer and use it in GitHub Desktop.
How to use file system 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 wrt_file(char * dat, char * filename) { | |
FILE *file = fopen(filename, "w"); | |
fprintf(file, dat); | |
fclose(file); | |
} | |
void rd_file(char * filename, char * file_str) { | |
int c; | |
int idx = 0; | |
FILE *file; | |
printf("filename: %s\n", filename); | |
file = fopen(filename, "r"); | |
if (file) { | |
while ((c = getc(file)) != EOF) { | |
file_str[idx] = c; | |
idx++; | |
} | |
fclose(file); | |
} | |
printf("filedat: %s\n", file_str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment