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-28 8:20

#include <stdlib.h>

char* a="one";
char* b="two";
char* c="three";
char* d=malloc(sizeof(char)*(strlen(a)+strlen(b)+strlen(c)+1));

strcpy(d,a);
strcpy(*d+strlen(a),b);
strcpy(*d+strlen(a)+strlen(b),c);

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