Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anon 2009-01-28 2:07

Hey, I am a complete noob to c++, and I need to know how to add strings.

Eg, I have:
a="one"
b="two"
c="three"

and I would like "d" to equal "onetwothree".

Thank you for any help

Name: Anonymous 2009-01-29 4:11

size_t al = strlen(a), bl = strlen(b), cl = strlen(c);
char *d = malloc(al + bl + cl + 1);
memcpy(d, a, al);
memcpy(d + al, b, bl);
memcpy(d + al + bl, c, cl);
*(d + al + bl + cl) = 0;


Or, since OP asked about Sepples:
std::string a = "one", b = "two", c = "three", d = a + b + c;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List