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 / help adding strings together

Author
Message
zao420
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location: Canada
Posted: 3rd Jan 2005 05:36
HI everyone,
I am new to c++ and ran into a few problems, I am tring to add twp string together using.

char* charset[4][17]

char* name // is part of a type

then i go to build the player name.
Player[0].Name = Player[0].Name + CharSet[Y_Letter][X_Letter];

but i get an error that i can't add to pointers. well doing some search on this, i came across some stuff about using std::string so i gave that a try now some function call to darksdk don't work so i guss thats not an option.

http://cavesoft.no-ip.com
WIP Version of my site. Usally it is offline.
http://dev-cavesoft.no-ip.com
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jan 2005 06:03
STD should work okay.

As I dont use it, the easiest way to add two strings together is to use strcat.

Visit http://homepages.nildram.co.uk/~nickk/
I have no signature.
zao420
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location: Canada
Posted: 3rd Jan 2005 12:17
when i use std i get error C2664: 'dbCenterText' : cannot convert parameter 3 from 'std::string' to 'char *'
error C2664: 'dbLen' : cannot convert parameter 1 from 'std::string' to 'char *'

Maybe there is a step i missing.

http://cavesoft.no-ip.com
WIP Version of my site. Usally it is offline.
http://dev-cavesoft.no-ip.com
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jan 2005 18:13
Lets see the code.

Visit http://homepages.nildram.co.uk/~nickk/
I have no signature.
zao420
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location: Canada
Posted: 4th Jan 2005 07:33
// in the header file.
typedef struct tPlayer
{
std::string Name;
int MaxHp;
int MaxMp;
int Hp;
int Mp;
int Exp;
int Lv;
int Atk;
int Def;
int Agi;
int Str;
int E_Weap;
int E_Arm;
int E_Shd;
float X;
float Y;
float Z;
int Obj;
} tPlayer;

tPlayer Player[1];
std::string CharSet[4][17];

// in cpp file

dbCenterText ( X_Screen,Y_Screen-1,Player[0].Name );

if ( dbLen ( Player[0].Name ) < 10 )
{
//Limit is 9 char.
Player[0].Name = Player[0].Name + CharSet[Y_Letter][X_Letter];
}

http://cavesoft.no-ip.com
WIP Version of my site. Usally it is offline.
http://dev-cavesoft.no-ip.com
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jan 2005 20:52
You can use std::string with the DarkSDK ... it's just that you currently have to override some warnings/errors to get it to compile cleanly.



I've asked Mike to change the SDK in the next version to allow 'const char*' for all commands that accept strings instead of 'char *' so that we can avoid this potentially dangerous casting.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-03-29 09:04:22
Your offset time is: 2024-03-29 09:04:22