I am writing code in VS2010 and I happen to see after compilation compiler gives me C4996 warning (\"This function or variable may be unsafe\") for strcpy and sprintf calls.
Because strcpy
and sprintf
really are unsafe functions, it depends on the content of the string to not overflow. Instead you should use strncpy
and snprintf
to make sure it does not overwrite the memory.
While memcpy
is not this case, it has the length so it does not overwrite memory as long as the length is correct.