Strings, need help

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Sebastiaan
Engineer
Engineer
Posts: 110
Joined: 20 Jun 2005 19:22
Location: Leuven, Belgium

Strings, need help

Post by Sebastiaan »

I'm trying to write data about the players and their companys to a file to allow statitics to be made out of them.

I managed to figure out how to retrieve the content of a string, ie. president_name and name, but i cannot do the same for an int like player_money.

How can i convert an int (int32) to a string or, if no such function exists, how can i output such a number to a file?

thanks a lot.

ps: please do say google or read the code, because i tried both.. :oops:
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

if you're using normal printing routines from C then the function you need is (w)sprintf(char * outputbuffer, char * patternstring, arguments...);

you'd use it like: sprintf(buf,"%d",player_money);
the pattern string defines how the integer should be printed. for an explanation on how to use it, google :twisted:
Sebastiaan
Engineer
Engineer
Posts: 110
Joined: 20 Jun 2005 19:22
Location: Leuven, Belgium

Post by Sebastiaan »

Thank you very much :)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 14 guests