The memcpy
function is declared in <string.h>
.
The malloc
function is declared in <stdlib.h>
.
Your system should have some documentation that tells you, for each library function, which header you need to #include
to use it (and possibly what library you have to specify to link to it). (If you were on Unix or Linux, I'd suggest the man page.) Failing that, a web search for the function name will probably give you the information (though there's also plenty of bad information out there).
For MS Windows, MSDN has a lot of online documentation. For example, a Google search for "MSDN malloc" turns up this page -- which, unfortunately, also mentions the non-standard <malloc.h>
header, without making it clear that it's non-standard.
A web search for "man malloc" will give you results that might be more Unix-specific, but for the standard functions that shouldn't be much of a problem.
Incidentally, <cstring>
is a C++ header; it's the C++ version of C's <string.h>
. If you want to write C code, be sure you're invoking your compiler as a C compiler. (Naming your source file with a .c
extension is sometimes enough to do this.)