Server Help

Bot Questions - Reading INIs

Cyan~Fire - Sat Aug 23, 2003 5:58 pm
Post subject: Reading INIs
Can someone outline how to access an INI file from a DLL? Thanks.
Smong - Sun Aug 24, 2003 11:20 am
Post subject:
You could use fopen() and fgets()
Cyan~Fire - Sun Aug 24, 2003 1:59 pm
Post subject:
Uhhh...
Pretend I'm an idiot icon_biggrin.gif
How do you use them?
Smong - Sun Aug 24, 2003 3:56 pm
Post subject:
Code: Show/Hide

//<edit>
#include <stdio.h>
//</edit>

readExample()
{
  FILE *conf;
  char line[256];
  int i, j;

  //Open file for reading
  conf = fopen("settings.ini", "r");
  if (!conf) return;

  //Get the first line
  i = fgets(line, 256, conf);
  if (i > 0) //Make sure there is something on it
  {
    sscanf(line, "%d", &j); //Convert to integer
  }

  //Close the file
  fclose(conf);
}

There's probably a class with merv bot that can do .ini files, but I wouldn't know which file it was in.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group