sizeof(T)
gives the amount of memory that an object of type T requires. If T is a variable, then the type of this variable is used.
With char* param_1
, expression sizeof(param_1)
gives you the memory that type char*
requires, i.e. the size of a pointer. This is likely to be always 8
(the size a pointer needs on a 64bit machine). But it is definitely not the length of the string to which param_1
points to.
correct would be...
int n = strlen(param_1) + 1;
The + 1
is required, because every string needs an additional terminating character at the end. By +1
, this is copied together with the actual content.