My code has a semicolon ;). When I copied it in I must have accidentially removed it.
If there was no semicolon, the code itself would not compile.
Printable View
My code has a semicolon ;). When I copied it in I must have accidentially removed it.
If there was no semicolon, the code itself would not compile.
I know that, just pointing it out
Code:EXPRESSION(
/* ID */ 0,
/* Name */ "Name(",
/* Flags */ EXPFLAG_STRING,
/* Params */ (1,EXPPARAM_STRING,"Parameter")
) {
char * str1 = (char *)"1st String";
char * str2 = (char *)ExParam(TYPE_STRING);
char * str3 = rdPtr->rRd->GetStringSpace(strlen(str1) + strlen(str2) + 1);
strcpy(str3, str1);
strcat(str3, str2);
ReturnString(str3);
}
Raw strings in C are a pain...
But you could also use C++ CStrings like this:
Code:EXPRESSION(
/* ID */ 0,
/* Name */ "Name(",
/* Flags */ EXPFLAG_STRING,
/* Params */ (1,EXPPARAM_STRING,"Parameter")
) {
CString str1 = "1st String";
CString str2 = (char *)ExParam(TYPE_STRING);
CString str3 = str1 + str2;
ReturnStringSafe(str3.c_str());
}
With Dynasoft's code my extension does not compile. It seems like CString has not been included. How can I include it?
Can you tell I haven't used them for a while :P
I got CString (a microsoft specific thing) and string (the C++ standard one) confused. Replace all the CString in my code with string, and add:
EDIT: So this:Code:#include <string>
EDIT: No + operator, only += apparently, so change like this:
EDIT3: Scratch that last edit
Code:#include <string>
EXPRESSION(
/* ID */ 0,
/* Name */ "Name(",
/* Flags */ EXPFLAG_STRING,
/* Params */ (1,EXPPARAM_STRING,"Parameter")
) {
string str1 = "1st String";
string str2 = (char *)ExParam(TYPE_STRING);
string str3 = str1 + str2;
ReturnStringSafe(str3.c_str());
}
There is a + operator for std::string.
It wasn't listed in the online c++ help I looked at.
EDIT: Changed my post back.
Thanks everyone (Especially Dynasoft for his code)! It works now.