Advertisement Jump to content


This topic is now archived and is closed to further replies.


reading ini file?

This topic is 5831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there some easy way to read a .INI file? I have written my own function to read/find whatever variable i need, however.... How do I set them?? My .ini file is set up like this [SECTION HEADER] <---worthless, just for my own orginization variable = x; somebool = true; somefloat = 6.0525f; [SECTION HEADER] <--- same as before go on ect, ect. Anyways, when I store variable = x into an array, how do i have it set that variable?? My function is this (if this is wrong setup, please tell me) bool INI::Input(char* variable, char* type) variable is the variable im looking for, and type is the type (float, bool, int, ect) anybody have some help?? Maybe an easier way?

Share this post

Link to post
Share on other sites
you can overload Input for different types, like so:

// reads 'name' as a float
bool Input(string name, float& value);

// reads 'name' as an integer
bool Input(string name, int& value);

// reads 'name' as a string
bool Input(string name, string& value);

// reads 'name' as a boolean
bool Input(string name, bool& value);


[edited by - niyaw on January 31, 2003 11:38:53 PM]

Share this post

Link to post
Share on other sites
I don''t know for sure, but wasn''t there an API for reading INI files? Or was it a special statement in Delphi?

Right, now I''m confused!

But why make an INI file? Isn''t writing in the Registry a little bit easier (when you know how to do it)?

Share this post

Link to post
Share on other sites
Writing to the registry is similiar to INI files. I personally prefer INI-files but thats totally up to you...

GetPrivateProfileString("Section", "Key", DefaultValue. etc..)


see MSDN for more info on that

Share this post

Link to post
Share on other sites
for API based INI support, u do have the GetPrivateProfileInt/String functions. but i think they''re windows specific. for general support, u''re probably left to ur own devices

on registry settings, i guess its a preference. also, it is windows only and not everyone codes for windows. besides, the registry if not handled well can be like opening Pandora''s Box. if ppl can erase their harddisks by misuse of the IO functions, imagine wat can happen to Windows if ur registry manipulation code screws up. just a thought

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!