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 / Printing text on screen

Author
Message
archie456
16
Years of Service
User Offline
Joined: 13th Feb 2008
Location:
Posted: 17th Feb 2008 23:20
Hi,

A newbe question...

I want to print some messages on the screen. I'm doing this:

char mymessage[] = "Hello";
dbPrint (mymessage);

This works OK - but how do I add messages together? i.e.

char mymessage[] = "Hello";
mymessage = mymessage + " world";
dbPrint (mymessage);

Thanks for any advice!
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 18th Feb 2008 15:40
There are many C/C++ functions that can be used, like 'strcat', also you better end your strings with a termination char '\0':

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Feb 2008 15:58
Zero-termination is automatic; it's not necessary to do yourself.

As for the original question, I'd keep a buffer available to do string operations with. If you want to add two strings together, write the first one to the buffer with strcpy, then append the second one using strcat, both of which are defined in string.h:



Note that if you specify a dynamically allocated buffer to copy into, you must use the non '_s' version of these functions, or pass in the size of the buffer as the second parameter.

Login to post a reply

Server time is: 2024-11-17 06:47:24
Your offset time is: 2024-11-17 06:47:24