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 / "Folder\\" + "something.bmp" <-- i'd like to do that somehow

Author
Message
dogzer
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location:
Posted: 1st Feb 2006 00:54
I suffer from a rare c++ coding discapability, so plz bare with me..
I'd like to be able to add two texts together, to make a composed resulting text. What solutions are there to this problem?

I tried the strcat(), but i had endless problems, and i wasnt able to use it in the end.
I also tried using the "string stringName" thing, i managed to print it as if it was a (char*), but i wasnt able to add them together either.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 1st Feb 2006 09:05
You have three choices :

A) MFC & CString** :
CString temp;

temp=CString("\\")+CString("file.bmp");

B) strcpy & strcat
strcpy(temp,"\\"); <- Note double backslash
strcat(temp,"file.bmp");

In VS 2005*, they recommend you use the new security enhanced versions :
strcpy_s(temp,sizeof(temp),"\\");
strcat_s(temp,sizeof(temp),"file.bmp");

C) STL - Never used it, so cant help there

* - Doesn't currently work with DarkSDK
** - Requires a lot of extra work to get it working with DarkSDK

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
scooby bloke
20
Years of Service
User Offline
Joined: 4th Nov 2004
Location:
Posted: 1st Feb 2006 11:22 Edited at: 1st Feb 2006 11:23
Using STL




Much easier than all that strcpy stuff, much smaller than the MFC stuff (quicker than MFC too), and works fine with the sdk .
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 2nd Feb 2006 09:05 Edited at: 2nd Feb 2006 09:08
I use (std: <string> and <stringstream>, works perfectly.
(also converting integers and floats to strings is really easy with stringstreams, << and >> operator )

ps: you need to convert to char* (LPSTR) if you want to pass your string to a DGDK function.

macro string2lpstr




//edit: maybe this is useful: "can't get char arrays to work"
http://forum.thegamecreators.com/?m=forum_view&t=67003&b=22

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 4th Feb 2006 10:18
sprintf(), why does everyone over look it x.x

assuming filepath contains "file.bmp" or whatever:

sprintf(temp, "\\%s", szFilepath);

lots of formatting options usually make sprintf my favourite choice for building strings from data.

OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 4th Feb 2006 11:21
Considering I use it a lot, its odd that I forgot it...

The security enhanced version is sprintf_s(temp,sizeof(temp),"\\%s",szFilepath);

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 6th Feb 2006 10:16 Edited at: 6th Feb 2006 10:18
The appearance of sprintf scares me, it just looks ugly and confusing hehe
My favourite is still std strings and stringstreams.

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;

Login to post a reply

Server time is: 2024-11-19 04:38:39
Your offset time is: 2024-11-19 04:38:39