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 / Strings and dbPrint

Author
Message
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 5th May 2008 21:40
When I try to run this:



I only get this errors:



The DarkGDK functions don't like strings. Why?
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 5th May 2008 21:53
instead of

put
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 6th May 2008 00:23
Or use text.c_str() instead of text. c_str() is a function that returns a pointer to the character data in the string.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 6th May 2008 21:32
I get same problem!

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 6th May 2008 22:35 Edited at: 6th May 2008 22:38
I use this for my strings (Note: Updated RECENTLY since last release of my oop lib). Note I also have added some string parsing things and I know they are not optimized.. but they work, and work in GDK quite nicely... so ... considering I wrote those and tested them over last couple days, I'm going to start using them myself tonight on a file directory type of parser thingy):

jfc_string.h



jfc_string.cpp




[edit] All the functions in the HEADER are implemented.. I left a comment in there to the contrary and removed it [/edit]

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 6th May 2008 22:49
Quote: "I get same problem!

+ Code Snippet

#include <string>
#include "DarkGDK.h"

using namespace :: std;

void DarkGDK()
{
dbSyncOn();

while(LoopGDK())
{
string text = "Lol";
dbPrint(text.c_str());
dbSync();
}

return;
}"


Just for performance sake I'd move the

string text = "Lol";

out of the loop. The optimizer may deal with it but to all appearances it looks like you're reassigning the string over and over when you don't need to.

I'm not sure, but is the scope resolution operator valid in your "using namespace" directive?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 6th May 2008 22:57
this line:

dbPrint(text.c_str());

needs to be changed to this:

dbPrint( (char*)text.c_str() );

Microsoft Windows = BSOD
Microsoft XBOX 360 = RROD
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 7th May 2008 22:04
Thanks alot!

Login to post a reply

Server time is: 2024-11-20 09:33:36
Your offset time is: 2024-11-20 09:33:36