fileio.cpp ¶
~cpp #include <stdio.h> #include <string.h> void saveToFile(char *filename, char *str) { FILE *file = fopen(filename, "wb"); fwrite(str, strlen(str), 1, file); fclose(file); } long loadFromFile(char *filename, char *str) { FILE *file = fopen(filename, "rb"); fseek(file, 0, SEEK_END); long len = ftell(file); fseek(file, 0, SEEK_SET); fread(str, len, 1, file); str[len] = '\0'; fclose(file); return len; }