I don't know of any standard C functions, it's not hard to do something using fprintf and fscanf. Here's how I did it in an IDE I'm writing (remove the 'g' from the beginning of gfree, gint, gchar, etc. if you're not using GTK). I think you should get the general idea.
/* READING SETTINGS FROM THE FILE */
gchar *path = g_build_filename(g_getenv("HOME"), ".asmide", NULL); //get the path to the config file
FILE *configfile = fopen(path, "r"); //and try to open the file
if (configfile == NULL) { //if it doesn't exist,
gtk_window_set_default_size(window, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
PangoFontDescription *font = pango_font_description_from_string(DEFAULT_FONT);
gtk_widget_modify_font(text, font);
pango_font_description_free(font); //and use default settings
*color_label = g_strdup(DEFAULT_COLOR_LABEL);
*color_comment = g_strdup(DEFAULT_COLOR_COMMENT);
*color_directive = g_strdup(DEFAULT_COLOR_DIRECTIVE);
*tabwidth = DEFAULT_TAB_WIDTH;
*output_type = g_strdup(DEFAULT_OUTPUT_TYPE);
*usesyncolor = TRUE;
} else {
gchar rawinput[100], fontname[50];
gint window_width = 0, window_height = 0;
*usesyncolor = TRUE;
*tabwidth = 0;
while (!feof(configfile) && fscanf(configfile, "%99[^\n]\n", &rawinput) != 0) { //otherwise, read a line from the file
if (g_str_has_prefix(rawinput, "WindowWidth=")) //parse recognized properties
sscanf(rawinput + 12, "%d", &window_width);
else if (g_str_has_prefix(rawinput, "WindowHeight="))
sscanf(rawinput + 13, "%d", &window_height);
else if (g_str_has_prefix(rawinput, "Font="))
sscanf(rawinput + 5, "%49[^\n]\n", &fontname); //TODO: add error checking?
else if (g_str_has_prefix(rawinput, "ColorLabel="))
*color_label = g_strndup(rawinput + 11, strlen(rawinput) - 11);
else if (g_str_has_prefix(rawinput, "ColorComment="))
*color_comment = g_strndup(rawinput + 13, strlen(rawinput) - 13);
else if (g_str_has_prefix(rawinput, "ColorDirective="))
*color_directive = g_strndup(rawinput + 15, strlen(rawinput) - 15);
else if (g_str_has_prefix(rawinput, "OutputType="))
*output_type = g_strndup(rawinput + 11, strlen(rawinput) - 11);
else if (g_str_has_prefix(rawinput, "SyntaxColoring="))
sscanf(rawinput + 15, "%d", usesyncolor);
else if (g_str_has_prefix(rawinput, "TabWidth="))
sscanf(rawinput + 9, "%d", tabwidth);
else
fprintf(stderr, "asmide: Unrecognized property %s in config file\n", rawinput); //if it's an invalid property, show an error
} //continue until the end of the file
fclose(configfile);
if (window_width <= 0) //do some sanity checks for properties
window_width = DEFAULT_WINDOW_WIDTH;
if (window_height <= 0)
window_height = DEFAULT_WINDOW_HEIGHT;
if (*color_label == NULL)
*color_label = g_strdup(DEFAULT_COLOR_LABEL);
if (*color_comment == NULL)
*color_comment = g_strdup(DEFAULT_COLOR_COMMENT);
if (*color_directive == NULL)
*color_directive = g_strdup(DEFAULT_COLOR_DIRECTIVE);
if (*output_type == NULL)
*output_type = g_strdup(DEFAULT_OUTPUT_TYPE);
if (*tabwidth <= 0)
*tabwidth = DEFAULT_TAB_WIDTH;
gtk_window_set_default_size(window, window_width, window_height); //then set the properties
PangoFontDescription *font = pango_font_description_from_string(fontname);
gtk_widget_modify_font(text, font);
pango_font_description_free(font);
}
g_free(path);
/* WRITING SETTINGS TO THE FILE */
gchar *path = g_build_filename(g_getenv("HOME"), ".asmide", NULL); //get the path to the config file
FILE *configfile = fopen(path, "w"); //and try to open the file
if (configfile == NULL) { //if it couldn't be opened,
GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Can't open configuration file\n%s to write settings!", path);
gtk_message_dialog_format_secondary_text(dialog, "Your permissions must be really\nscrewed up if you don't have write\naccess to your home directory.");
gtk_dialog_run(dialog); //show a warning dialog
gtk_widget_destroy(dialog);
} else { //otherwise,
gint window_width, window_height;
gchar *fontname;
gtk_window_get_size(window, &window_width, &window_height); //get the properties
fontname = pango_font_description_to_string((gtk_widget_get_style(text))->font_desc);
fprintf(configfile, "WindowWidth=%d\nWindowHeight=%d\nFont=%s\nColorLabel=%s\nColorComment=%s\nColorDirective=%s\nOutput Type=%s\nSyntaxColoring=%d\nTabWidth=%d\n", window_width, window_height, fontname, color_label, color_comment, color_directive, output_type, usesyncolor, tabwidth); //and write them to the file
g_free(fontname);
fclose(configfile);
}
g_free(path);