I don't care about the NULL terminator so I have two choices:
strcpy(createTabStmt, "CREATE TABLE "); //shorter and more readable code
Or
memcpy(createTabStmt, "CREATE TABLE ", sizeof ("CREATE TABLE ") - 1); //faster?
Is the memcpy
version always faster?
--
If that's true, then I think a macro can make the readability as good as strcpy
:
#define MEMCPY_LITERAL(ptr,literal) memcpy(ptr, literal, sizeof (literal) - 1)
--
I thought the memcpy
version has one more constant sizeof ("CREATE TABLE ") - 1
. So it uses more space. Is that true?