Qarvos
Qarvos

Reputation: 11

How 21 letter size string could settle into 16 bytes of RAM

C:

char kral[16] = "Kral "iyidir"";

char kralis[] = "Heheheha";

strcat(kral, kralis);

printf("%ld, %s", sizeof(kral), kral);

In this code I thought it will throw stack error, but it runs without error.But when I change array size of kral to 15, it throws stack error. Error:

*** stack smashing detected ***: terminated Aborted (core dumped)

My question is this: How 21 letter size string could settle into 16 bytes of RAM.And if can, why 15 bytes of RAM couldn't?

Getting answer for my question

Upvotes: 0

Views: 67

Answers (0)

Related Questions