#include config.cfg
Is it right?
And what must stay in the config.cfg?
Must I use spezial commands in the config.cfg?
#include config.cfg
Code: Select all
#USETHISCONFIGPLZ "config.cfg"
Code: Select all
void LoadConfig() {
FILE* f;
f=fopen("config.ini","r");
int i;
if (!f) {
printf("FAIL!\n");
}
else {
char line[100];
char l2[100];
char value[100];
while (!feof(f)) {
fgets(line,100,f);
char *tmp;
if (line[0] == '#')
continue;
if (line[0] == '[') {
tmp = strchr(line, ']');
if (!tmp)
continue;
*tmp = 0;
memset(l2,0,100);
strcat(l2,line+1);
continue;
}
if ((tmp = strchr(line, '='))) {
*tmp = 0;
tmp++;
memset(value,0,100);
strcat(value,tmp);
//l2 = SECTION
//line = ident
//value = value :)
if (strcmp(l2,"ACCOUNT") == 0) {
if (strcmp(line,"login")==0) { memset(cLoginData[0],0,20); strcat(cLoginData[0],value); }
if (strcmp(line,"password")==0) { memset(cLoginData[1],0,20); strcat(cLoginData[1],value); }
}
}
}
fclose(f);
printf("OK!\n");
value[i]=0;
cLoginData[0][strlen(cLoginData[0])-1]=0; //dunno why :)
cLoginData[1][strlen(cLoginData[1])-1]=0;
//printf("Login: %s Password: %s\n",cLoginData[0],cLoginData[1]);
}
}
Code: Select all
cLoginData[0][strlen(cLoginData[0])-1]=0; //dunno why :)