Output is:Hello Hello As you can see the image Can someone tell why I am getting this output! Destination is Capable of holding only one character then how it can print entire string.
Asked
Active
Viewed 90 times
1 Answers
0
Please include the core part of your code otherwise we can't help you.
However, keep in mind that in C there is no automatic memory allocation, garbage collector and string type (which is an array of characters instead).
strcpy
copies the entire source string to the pointer specified as the destination and stops only when it finds the NULL
or \0
character regardless of how large the destination buffer is.
What happens is definitely a buffer overflow, the data following the destination buffer (of one byte) is overwritten, potentially causing program instability and data corruption.

Marco Sacchi
- 712
- 6
- 21
-
Thanks . Now I understood the problem – PRAVEEN KUMAR Sep 17 '21 at 15:26