I have a code like this, which is solved by me following a exercise problem from K&R book:
#include<stdio.h>
void stringCat(char *s,char *t)
{
    while(*s++);
    while((*s++ = *t++));
}
void main() 
{
    char message1[] = "hello whats been up?";
    int i;
    char message2[] = "this should be added at last";
    stringCat(message1,message2);
    for(i=0;i<50;i++)
    {
        printf("%c\n",message1[i]);
    }
}
The program works as intended to be and also I get output like this :
hello whats been up?this should be added at last
But I get an error followed by the output :
** stack smashing detected : ./a.out terminated ======= Backtrace: ========= */lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)Aborted*
I came to know why does this occur from here. But I couldn't able to figure out why does this thing happens in my code?
I'm a newbie in C, I need your help. Thanks in advance.
 
     
     
     
    