Jump to content


*.INI Files


23 replies to this topic

#1 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 01 October 2003 - 09:39 AM

How do we use the *.INI files. I mean to read and write to them ?
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#2 bladder

    DevMaster Staff

  • Moderators
  • 1057 posts

Posted 01 October 2003 - 02:05 PM

Just as you would any other file.

Either use ofstream and ifstream or do it the C way, ie: FILE* fread/fwrite. Nothing special about them. They're mostly just text files anyway.

#3 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 01 October 2003 - 03:00 PM

I knwo how to open other files ... but it has spaces and braces [] ? I just know to read and write a structure or some variables to the files without any spaces :blush: !
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#4 bladder

    DevMaster Staff

  • Moderators
  • 1057 posts

Posted 01 October 2003 - 03:15 PM

reading ini files

FILE* fp = fopen( "file.ini", "r" );

char c;

while( c = fread( &c, 1, 1, fp ) )
{
  if( c == ' ' )
    cout<< "A space! A space! w00000t"<< endl;
  
}


writing to ini files
FILE* fp = fopen( "file.ini", "a+" );

char someText[256];

strcpy( someText, "text with spaces" );

fwrite( someText, 1, strlen(someText)+1, fp );



#5 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 01 October 2003 - 03:45 PM

i know i just made a post about respect for other people but this is basic knowledge... get a book on c/c++ and use the msdn library. don't you think that this is something you could have figured out yourself ? i don't mind you asking but i doubt the learning effect for yourself. think about it...
If Prolog is the answer, what is the question ?

#6 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 01 October 2003 - 04:24 PM

hehe, your limit of respect is lower than my one it seems. but not by much:D
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#7 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 01 October 2003 - 07:04 PM

:lol: :lol: :lol:
If Prolog is the answer, what is the question ?

#8 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 02 October 2003 - 03:10 AM

Sorry I ask :confused: !
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#9 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 02 October 2003 - 09:27 AM

don't look into the world that sad!

oh, and, yes, there is, in the win32 api, a special api to manipulate .ini files actually. never used it myself, though..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#10 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 02 October 2003 - 11:18 AM

no don't be sorry... as i said i don't mind you asking at all. i'm even glad to answer any question you have (as i hopefully did in the past ). it's just that i think that you can learn a lot more when playing around with your code until it works. especially when it is basic stuff like reading an parsing text from a file.
If Prolog is the answer, what is the question ?

#11 cjp88can

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 01 September 2004 - 07:44 AM

Here's a tip don't bother with ini for game data unless you really need to. Look what happend to some of the Command & Conqour games from ini files. (Mod making).

#12 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 01 September 2004 - 07:48 AM

necromancy? well.. anyways, yeah, today, xml is way to go :D
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#13 cjp88can

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 01 September 2004 - 07:55 AM

Yea xml would be a lot better I guess. One more thing TheLionKing if you ever make an online game down the road and use ini files to state levels and such of a player or whatever it is, don't have it with a client lol so many people do that and then think how people got their stats so high. So if you use ini run it with the server and let the client read and write data through it.

#14 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 01 September 2004 - 12:44 PM

yeah... posting in stone age threads !!!
hey dave i got xml serialization over the network working yesterday :)
If Prolog is the answer, what is the question ?

#15 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 01 September 2004 - 12:57 PM

great! i was playing a bit with rss - saving, and i am able now to do some sort of news-posting into xml directly. now i should handle it over net, too :D
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#16 cjp88can

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 01 September 2004 - 03:24 PM

anubis said:

yeah... posting in stone age threads !!!
hey dave i got xml serialization over the network working yesterday :)

View Post


Lock me up and throw away the key. :nervous:

#17 NomadRock

    Senior Member

  • Members
  • PipPipPipPip
  • 785 posts

Posted 01 September 2004 - 03:29 PM

Is there any way to lock old threads. This really got to be a problem in flipCode and could easily kill this site too...
Jesse Coyle

#18 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 01 September 2004 - 04:18 PM

yes there is... or do you mean autmatically ? maybe that can be implemented
If Prolog is the answer, what is the question ?

#19 NomadRock

    Senior Member

  • Members
  • PipPipPipPip
  • 785 posts

Posted 01 September 2004 - 04:35 PM

Yes, I mean if a thread hasn't been posted in for at least X months, then it is automatically locked.
Jesse Coyle

#20 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 01 September 2004 - 05:50 PM

that would be a good idea. i'm sure Dia can do this
If Prolog is the answer, what is the question ?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users