I have the following code:
int dst[5];
int src[100];
// assign value to array src
memcpy(&dst[0], &src[0], sizeof(int) * 100);
what will happen in this case? will only the first 5 elements is copied to array dst
?
or the program will crash?
This invokes undefined behaviour. Anything could happen.
In practice, what will probably happen is that memory outside of dst
will be overwritten, trashing something else, and therefore corrupting the state of your program. The best-case scenario is that this causes your program to crash.