Hi!
I have a function which saves properties of the program into the setup.cfg file. There are two properties to be saved. My problem is that when I want to save just one propertie I have to read the whole setup.cfg file and save the previous properties into the temporary variable. Is there any way to avoid this? If not, is there any other solution?
Here's my code:
Code:
typedef struct
{
char LanguageFile[30];
BOOL StatusLine;
} Properties;
# define SETUP_FILE "./DATA/setup.cfg"
int main ()
{
FILE *fin = NULL;
Properties File;
char Temp[30];
if ((fin = fopen (SETUP_FILE, "rb")) != NULL)
{
fread (&File, sizeof (Properties), 1, fin);
strncpy (Temp, File.LanguageFile, strlen (File.LanguageFile) + 1);
strncpy (File.LanguageFile, Temp, strlen (Temp) + 1);
}
fclose (fin);
if ((fin = fopen (SETUP_FILE, "wb")) != NULL)
{
strncpy (File.LanguageFile, Temp, strlen (Temp) + 1);
File.StatusLine = TRUE;
fwrite (&File, sizeof (Properties), 1, fin);
}
fclose (fin);
}