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 / best way to print text using dbText ( 50,100, "Screen width :- " + dbStr(scr_width )) ??

Author
Message
stevebrit
15
Years of Service
User Offline
Joined: 6th Jan 2009
Location: Florida USA
Posted: 28th Jan 2009 18:29
hello folks can anyone please tell me the best way to print text with an added int value

the following will not work because the + is seen by c++ as a pointer.

dbText ( 50,100, "Screen width :- " + dbStr(scr_width ));

what is the best way to do this in c++

regards :- Steve

AMD Athlon64x2 3.1Ghz - Ram 4Gb - 500Gb HD
Ndivia 9600GT SLI - 24in LCD
Orac
18
Years of Service
User Offline
Joined: 16th May 2006
Location: Billingham
Posted: 28th Jan 2009 21:04
Here's one to do it using standard function sprintf(), may not be the best but it works.



You can use other modifiers in place of %s and %d, like %f for float or %x for hexadecimal.

Of all the things I've lost .. I miss my marbles most of all.
stevebrit
15
Years of Service
User Offline
Joined: 6th Jan 2009
Location: Florida USA
Posted: 28th Jan 2009 21:09
Hello i found a solution to my problem in the forum it was as follows :-

char pBuf[64];


sprintf(pBuf,"Screen resolution %d %d ",scr_width,scr_height);
dbText(100,100,pBuf);


in this instance the output to screen is
---
Screen resolution 1024 768
---
where scr_width and scr_height are both int values

regards :- Steve

AMD Athlon64x2 3.1Ghz - Ram 4Gb DDR2 800Mhz - 500Gb HD
Ndivia 9600GT SLI - 24in LCD - WIN 7 - 64 bit BETA
stevebrit
15
Years of Service
User Offline
Joined: 6th Jan 2009
Location: Florida USA
Posted: 28th Jan 2009 21:12
Well thank you sir i found that a little earlier on and it works great. Having previously used pascal and basic using C++ to concatenate strings came as a bit of a shock lol.....

have a nice day :- Steve

AMD Athlon64x2 3.1Ghz - Ram 4Gb DDR2 800Mhz - 500Gb HD
Ndivia 9600GT SLI - 24in LCD - WIN 7 - 64 bit BETA

Login to post a reply

Server time is: 2024-09-30 17:41:37
Your offset time is: 2024-09-30 17:41:37