Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read from INI file

Status
Not open for further replies.

jamescpp

IS-IT--Management
Aug 29, 2001
70
US
I have a c program that current takes args from the command line. Instead, I would like to have these stored in an INI file and read when the program starts.

Can anyone help, especially maybe a pointer to some example code? Please don't just point me to tutorials unless they are specific to this. I've tried that route and it's information overload, couldn't find what I was looking for.

Any help is appreciated.
James
 
#include<stdio.h>
int main()
{
char* buf[100];
some variables here
FILE* ff = fopen(&quot;xx.ini&quot;,&quot;r&quot;);
fscanf(ff,&quot;%s&quot;,buf);/*reading first word from
first record*/
if(!strcmp(buf, &quot;your ini variable name&quot;))
{
/*read second value from first record*/
fscanf(ff,&quot;%...&quot;,&somevariable);
}
return 0;
}
also you can put into a while loop
while(!feof(ff))
{
..read here
} Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top