Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / String Concatenation Function

Author
Message
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 17th Dec 2007 01:49 Edited at: 17th Dec 2007 01:52
I am in the process of writing a simple card game in order to learn c++.

I have a deck of cards from David G (Thanks David )
http://forumfiles.thegamecreators.com/?i=956493

edit : Here is the forum page http://forum.thegamecreators.com/?m=forum_view&t=67876&b=1&p=20

I need to load 52 cards as objects deck01.x, deck02.x through deck52.x

Would anyone be able to write a function in c++ that can concatinate the string "Deck" the integer and the string ".x"

Thanks in advance

Codger

p.s. I have spent 6 hours reading prior post and trying to code it myself with out sucess

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 17th Dec 2007 02:16 Edited at: 17th Dec 2007 02:17
One way is to use sprintf to print formatted data to a buffer. Just make sure the buffer is large enough.



Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 02:39
I do that tooo - In fact - I have a 1024 byte or so buffer I put in a "global Namespcce" for quick operations like that. Considered bad practice by some I'm sure - but - as long as you just use it and be done with it - you can have one buffer shared by all.

In fact - my "Print Statements look kinda like:



Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Dec 2007 16:21
std::string ftw

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 16:23
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 17th Dec 2007 17:07
For the win! Yeah, okay, it's also WTF backwards... I've been there...
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 20:35
FTL (For the loss)....

whatever you can get working

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 17th Dec 2007 22:48
1 Word: wow.... When I looked at it it did look like wtf at first.. I've been playing too much Halo... And Xbox Live lol.

dbPrint ( "Sig" );
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 18th Dec 2007 03:38
Here is the function I ended up with it loads all 52 cards from the default directory.



Thanks for the help

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Galaxy613
16
Years of Service
User Offline
Joined: 17th Dec 2007
Location: USA, VA
Posted: 18th Dec 2007 03:57
Yeah, sprintf works especially well there. If you were just appending it you could use StrCat.

Login to post a reply

Server time is: 2024-10-08 18:21:10
Your offset time is: 2024-10-08 18:21:10