Seriously?
I'm still not sure whether to take this seriously but what the heck!
C implements "strings" using char arrays with the end of the string flagged by a null (i.e. = 0). So create the char array of the necessary length and populate with the source pair.
/* start */
#include <string.h>
#include <stdio.h>
char *string1 = "one";
char *string2 = "two";
char* combination = (char*) malloc(strlen(string1) + strlen(string2) + 1);
strcpy(combination, string1);
strcat(combination, string2);
/* use combination in some way */
printf("%s\n", combination);
/* get rid off when finished with */
free(combination);
/* end*/
There are many variations on the above but should give you some pointers. Whatever you do though don't use DWORDs because they are not appropriate as pointers to data. Using LPSTRs is probably fine.
Life can be even easier if you use the C++ String class.
/* start */
#include <string>
#include <iostream>
using namespace std;
string string1("one");
string string2("two");
string combination(string1+string2);
/* use combination in some way */
cout << combination << endl;
/* end */
No need necessarily for new() & delete() because C++ allows declaration of variables at any point in function.
Could give you the java version but Microsoft and java don't really mix. Somebody else can give you the C# which probably looks same as C++ variant.
Ok, now tell me I've been had!
I'm still not sure whether to take this seriously but what the heck!
C implements "strings" using char arrays with the end of the string flagged by a null (i.e. = 0). So create the char array of the necessary length and populate with the source pair.
/* start */
#include <string.h>
#include <stdio.h>
char *string1 = "one";
char *string2 = "two";
char* combination = (char*) malloc(strlen(string1) + strlen(string2) + 1);
strcpy(combination, string1);
strcat(combination, string2);
/* use combination in some way */
printf("%s\n", combination);
/* get rid off when finished with */
free(combination);
/* end*/
There are many variations on the above but should give you some pointers. Whatever you do though don't use DWORDs because they are not appropriate as pointers to data. Using LPSTRs is probably fine.
Life can be even easier if you use the C++ String class.
/* start */
#include <string>
#include <iostream>
using namespace std;
string string1("one");
string string2("two");
string combination(string1+string2);
/* use combination in some way */
cout << combination << endl;
/* end */
No need necessarily for new() & delete() because C++ allows declaration of variables at any point in function.
Could give you the java version but Microsoft and java don't really mix. Somebody else can give you the C# which probably looks same as C++ variant.
Ok, now tell me I've been had!
Comment