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 / from darkbasic pro to dark gdk

Author
Message
MikeP
14
Years of Service
User Offline
Joined: 9th Oct 2010
Location:
Posted: 9th Oct 2010 12:01
Hi,
Recently I programmed a game in Darkbasic Professional and a few days ago decided to convert the code to darkGDK in C++. It hasn't worked out well. I am new to c++ but have years of experience in VB.NET and C#.NET. The problem is that when I try to print a string I get this error ini the output window:

1>c:\users\owen\documents\visual studio 2008\projects\dark gdk - game1\dark gdk - game1\main.cpp(231) : error C2665: 'dbPrint' : none of the 4 overloads could convert all the argument types
1> c:\program files (x86)\the game creators\dark gdk\include\darksdkcore.h(40): could be 'void dbPrint(LONGLONG)'
1> c:\program files (x86)\the game creators\dark gdk\include\darksdkcore.h(41): or 'void dbPrint(double)'
1> c:\program files (x86)\the game creators\dark gdk\include\darksdkcore.h(42): or 'void dbPrint(LPSTR)'
1> while trying to match the argument list '(std::string)'

at this point in the the code:

std::string invent;
invent = "myString";
dbPrint(invent);

I only started having trouble with my game when I began to add strings. The error only occurs if I add dbPrint(invent); to the code, otherwise it works fine. I've read the help file and I still don't know where i'm going wrong. It's probably something simple that I've forgotten to do or written wrong
Any help will be greatly appreciated,
thanks,
mike
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 9th Oct 2010 16:10
Simple: dbPrint expects a char pointer and you are giving it a string. All strings can return you the char pointer using the c_str() member function, but it's constant and dbPrint expects non-constant so:

MikeP
14
Years of Service
User Offline
Joined: 9th Oct 2010
Location:
Posted: 9th Oct 2010 18:25
Thanks mireben.
that code works

Login to post a reply

Server time is: 2024-11-19 18:30:32
Your offset time is: 2024-11-19 18:30:32