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 objects?

Author
Message
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 19th Jul 2009 20:49
How is it possible to get string objects in C++ with darkGDK... or is there some other way to emulate string objects with GDK?
Thanks for your help...
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 19th Jul 2009 21:18
You can use the <string> library, or you can use a c-string.

<string> method
Make sure you have included <string> in your source file


C-string


I recommend the c-string method, as it is most compatible with DarkGDK.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 20th Jul 2009 02:47
Okay, but what if I want to pass it through a function...
void funct ( int blah..., string MyString? )...
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 20th Jul 2009 09:04
Okay, this is what I have now... I can pass the C-style string to the function but I can't print it...

I declared the string like this:
char String[10] = "Text";

This is the call to the function:
attack (Pstren, String[10]);

This is the function:
float attack( float Pstren, char s) {
dbText ( 0, 0, s );
return Pstren;
}
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 20th Jul 2009 09:07
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 20th Jul 2009 09:14
Thank you very much dark coder... the sad thing is that I just read these tutorials-- cover to cover-- in April... seems I've already forgot...
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 20th Jul 2009 13:02
No doubt,

If you look at your function declaration: "float attack( float Pstren, char s)", the 2nd param is a 'char', a c-style string is not a single char, but an array of chars thus you must pass the pointer to a char, not a char itself.

Not to mention you're passing "attack (Pstren, String[10]);" which will be undefined memory.

Login to post a reply

Server time is: 2024-10-01 08:19:06
Your offset time is: 2024-10-01 08:19:06