Want to hold the original value after STRCAT | developer.brewmp.com Want to hold the original value after STRCAT | developer.brewmp.com

Developer

Want to hold the original value after STRCAT

Forums:

value = "1234";
newvalue = STRCAT(value,"&");

After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.

Rachel wrote:value = "1234";
newvalue = STRCAT(value,"&");
After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.
You are appending a new string with the original value and assigning to the same variable....how will it then store the original value??? :confused:
Use another variable for storing the appended value and free if after its use (assuming you are allocating memory to it).

Rachel wrote:value = "1234";
newvalue = STRCAT(value,"&");
After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.
You are appending a new string with the original value and assigning to the same variable....how will it then store the original value??? :confused:
Use another variable for storing the appended value and free if after its use (assuming you are allocating memory to it).

Rachel wrote:value = "1234";
newvalue = STRCAT(value,"&");
After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.
newvalue=STRDUP(value);
newvalue=REALLOC(newvalue,STRLEN(newvalue)+STRLEN("&")+1);
STRCAT(newvalue,"&");

Rachel wrote:value = "1234";
newvalue = STRCAT(value,"&");
After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.
newvalue=STRDUP(value);
newvalue=REALLOC(newvalue,STRLEN(newvalue)+STRLEN("&")+1);
STRCAT(newvalue,"&");

Rachel wrote:value = "1234";
newvalue = STRCAT(value,"&");
After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.
newvalue=STRDUP(value);
newvalue=REALLOC(newvalue,STRLEN(newvalue)+STRLEN( "&")+1);
STRCAT(newvalue,"&");
And remember, Rachel, to FREE(newvalue) after that has been used.

Rachel wrote:value = "1234";
newvalue = STRCAT(value,"&");
After STRCAT, value holds "1234&". How can I hold back the original value "1234" after STRCAT? I need the original value to pass to other function.
newvalue=STRDUP(value);
newvalue=REALLOC(newvalue,STRLEN(newvalue)+STRLEN( "&")+1);
STRCAT(newvalue,"&");
And remember, Rachel, to FREE(newvalue) after that has been used.

Thanks Dmitry.
Your solution solves my problem.

Thanks Dmitry.
Your solution solves my problem.