0 0 votes #include<string.h> #include<stdio.h> int main() { char str[13]="C at lakshya"; char str1[]="secret"; strcat(str,str1); printf("%d %d",sizeof(str),strlen(str)); } Output :- $13$ $18$ Here although sizeof str is $13$ then also it is concatenating why ? Programming in C programming-in-c programming output + – kd..... 695 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote Nice question. This is an undefined behavior. Because C doesn't do out of bounds checking, anything can happen when we try to read/write contiguously after the allocated memory of a predefined array. Explained here in detail: https://stackoverflow.com/a/30757295/8354936 Akhilesh Singla answered Apr 27, 2018 Akhilesh Singla comment Share Follow 0 reply Please log in or register to add a comment.