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 / Joining text

Author
Message
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 27th Nov 2009 13:51
in cpp how do u join text
in php its ., and in dbpro its +
but they dont work in cpp

eg
dbPrint("hi " + " how are you?");

how can i do this in cpp?



Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 27th Nov 2009 14:48
char text1[] = "hi";
char text2[] = " how are you?";
char final_text[30];

strcpy ( final_text, text1 );
strcat ( final_text, text2 );

or you can do it without text1/2 variables.

also you can:

char string[200];
sprintf ( string, "%s %s", text1, text2 );

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 27th Nov 2009 15:35
Use std::string instead as it's safer, if you need to add more than just strings then use std::stringstream.

Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 27th Nov 2009 20:16 Edited at: 27th Nov 2009 20:21
@dark coder
what is std::string

@hassan
so if i want to do:

i do


or



i dont quite understand you



Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 27th Nov 2009 20:26
simply:


here, you replace %d with a.

Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 27th Nov 2009 20:38
it automatically finds out the number a then?

if so
tyvm =)



Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 27th Nov 2009 20:41
for more info and things you can put in %d place, look at :
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/

Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 27th Nov 2009 20:47
Quote: "c:\documents and settings\admin\desktop\test sun\test sun\main.cpp(86) : error C2661: 'dbLoadImage' : no overloaded function takes 1 arguments"

well i did that and i got that



Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 27th Nov 2009 21:16
Try using %i instead of %d.

http://www.darkgdk.us/ <- You can now submit pages, upload images, yet were lacking content. We need your help!
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 28th Nov 2009 10:11 Edited at: 28th Nov 2009 10:11
no...dont..my bad, dbLoadImage ( img, a );
forgot the ID parameter

Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 28th Nov 2009 21:02
yeah i realized that just after i posted, ty again



Login to post a reply

Server time is: 2024-11-24 18:02:54
Your offset time is: 2024-11-24 18:02:54