File Read
#define LINE_MAX 128
const char *filename = "data.dat";
char line[LINE_MAX];
FILE* file;
file = fopen(filename, "r");
if(file)
{
while (fgets(line, LINE_MAX, file)) {
printf("%s", line);
}
fclose(file);
}
File Write
const char *filename = "data.dat";
FILE* file;
file = fopen(filename, "w");
if(file)
{
fputs("Line 1\n", file);
fputs("Line 2\n", file);
fputs("Line 3\n", file);
fclose(file);
}