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 / dbtext and strings

Author
Message
Ben_UK78
13
Years of Service
User Offline
Joined: 10th Jul 2010
Location:
Posted: 13th May 2012 00:29
I am a newbie at c++. I'm having a crack at it after programming basic for many years (using DB Pro for the last good while).

So. I thought I'd start with something simple. Load an object, put it at 0,0,0 and look at it. Well, it loads (or at least compiles), but I couldn't see it. So I thought I would have a look at a command similar to objectvisible in DB Pro.

So, now I get to the bit on my programmers checklist I thought wouldn't take more than an hour to solve - print text to the screen. Numbers are fine - convert a number to a string and print to the screen - oh oh, you need to solve world peace and then move on to the harder subject of strings in c++.

OK, so they are arrays and pointers - or some of them are, or seem to be.

I am coming from the world of basic. I have read multiple help pages, but DBtext is a command for this forum.

I'm not asking for someone to go to the trouble of explaining all of c++ string to me, just common errors
mine is : error C2664: 'dbText' : cannot convert parameter 3 from 'std::string' to 'char *'

-Can anyone give any quick advice for what DBtext is expecting - what will work and what won't?
-Also it seems that there are some really bad ways to program strings - is there a quick way of describing how it should be done, or a link to some reading material?
-If anyone has the time: why was it so so simple in DPPro to make strings, append them, and print them? It presumably just took all this away from the user?

Much thanks for any help. I can't solve world peace, but I'm determined to get my head around this.
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 13th May 2012 01:07 Edited at: 13th May 2012 01:09
'std::string' is an C++ string object. 'char*' is a c string.

See here for more information and usage example:

http://cplusplus.com/reference/string/string/c_str

http://keithschwarz.com/cs106l/spring2009/handouts/060_C_Strings.pdf

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 13th May 2012 13:48
To make things simple, I prefer to use this method:
Make a global

Then whenever I need to put some data on the screen


You don't need to solve for world peace, you just need to solve your piece of the world.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-03-29 07:55:00
Your offset time is: 2024-03-29 07:55:00