Raised This Month: $18 Target: $400
 4% 

Reading string name from .ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mikka
Junior Member
Join Date: Dec 2018
Old 07-28-2020 , 11:58   Reading string name from .ini
Reply With Quote #1

Hello, I have configs/names.ini in my file

Example: "Name" "Prefix".

What's the easiest way to read it into a variable?
Mikka is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-28-2020 , 14:48   Re: Reading string name from .ini
Reply With Quote #2

Code:
ReadFile() {     new szFilename[256]     get_configsdir(szFilename, charsmax(szFilename))     add(szFilename, charsmax(szFilename), "/YourFile.ini")     new iFilePointer = fopen(szFilename, "rt")     if(iFilePointer)     {         new szData[64], szKey[32], szValue[32]         while(!feof(iFilePointer))         {             fgets(iFilePointer, szData, charsmax(szData))             trim(szData)             switch(szData[0])             {                 case EOS, ';': continue                 default:                 {
                    parse(szData, szKey, charsmax(szKey), szValue, charsmax(szValue))
                }             }         }         fclose(iFilePointer)     } }
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-28-2020 , 14:52   Re: Reading string name from .ini
Reply With Quote #3

Use a trie, you will get some troubles with dyn array.
__________________
Shadows Adi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-28-2020 , 20:05   Re: Reading string name from .ini
Reply With Quote #4

Quote:
Originally Posted by Shadows Adi View Post
Use a trie, you will get some troubles with dyn array.
Without context, that shouldn't be the answer. It depends on what you want to do with it. While it might be likely that that is better, it's not a guarantee. Therefore, you should either provide at least one context in which it would be better to use a Trie and explain what you mean by "some troubles".
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:29.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode