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 / How to print a string variable?

Author
Message
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Jun 2013 22:13
If I have a variable like this

name = "George"

how do you print that out in DGDK? dbPrint(Name) does not work.
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 2nd Jun 2013 23:10
Ok Forget this post I got this



I am trying to port something that is all text in normal VC++ to GDK

7 Header files and 5 cpp files
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Jun 2013 13:25
You could just add a dbPrint overload to one of your commonly included header files / make a new one:



"Why do programmers get Halloween and Christmas mixed up?"
Dragon slayer
17
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 6th Jun 2013 21:54
That is a good idea!, I am still pretty inexperienced at C++, I know a lot but know there is tons more to learn. Not quite sure how this would work.

If I add this to a header file and just used the dbPrint command normally it would work? and would you be able to do the conversions the same way?, char to int and int to char?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Jun 2013 14:59
The risk is that writing for example dbPrint("Hello") would not compile due to it being ambigous; that could map to either the char* version or the std::string version (through an implicit cast).

But apart from that, yes, add it to a header file (that you include of course) and it should work. It's called function overloading and is a quite helpful feature.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-03-29 15:04:58
Your offset time is: 2024-03-29 15:04:58