I'm having a problem parsing an .ini
file
. I know there are lots of post on this topic, and I have read many of them. my ini
file
have only one entry
:
font=tahoma.ttf
Source Code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static FILE *ini_file;
char font[20];
void LoadConfig()
{
char Setting[20],Value[20];
int EndOfFile = 0;
if ((ini_file = fopen("config.ini", "r")))
{
EndOfFile = fscanf(ini_file, "%[^=]=%s", Setting, &Value);
while (EndOfFile != EOF)
{
if(strcmp(Setting,"font") == 0)
{
strcpy(font,Value);
}
EndOfFile = fscanf(ini_file, "%[^=]=%s", Setting, &Value);
}
fclose(ini_file);
}
}
The problem is that, the value is not never read into the font
variable
.