Strcpy () in c?

  c++, question

If you want to use strcpy () to assign character array a to b, there are some doubts:

char a[]="abcdef";
 char b[]="666";

Then the program is executed normally.
I think: in principle, the length of b is not enough, that is to say, the program actually uses the surplus numbers stored only after the last few of the current address of array b. Because this part of memory is temporarily useless, the output is normal.
Is my understanding correct? If not, what is the truth? If yes, how do I modify the code to make the results safe without using other data structures (such as vector).
Thank you all first.

The length of the target string will not be automatically increased;
The famous hacker attack method, buffer overflow, is based on this characteristic.
When calling strcpy(),strcat(),gets(),fgets () … and passing in a long string, if the programmer does not check the length of the source string. This will cause the memory immediately following the target string to be overwritten. If the memory records the return address of the function, then when the function returns, the program will try to jump to the place indicated by the address content (a pointer value) to continue execution. Thereby creating a security breach.
Try to use the security type functions corresponding to these functions.
For example: strncpy(),strncat () ..

If you encounter such problems, you can check them yourself first.