The C program here is giving out "Hello world" while running in Rethat Linux 
7.2 . It is compiled with ''gcc".

WHY NO CORE DUMP??? I have malloc only one byte.
Please explain me.


Kvimol
#include <stdio.h>
#include <stdlib.h>

void
my_strcat(char *dest, const char *src)
{
        while( *dest++ );
        dest--;

        while( *dest++ = *src++ );
        *dest=0;
}
char *
my_strcpy(char *dest, const char *src)
{
       int i=0;
       while (*src){
             dest[i++] = *src++;
       }
       dest[i]=0;
}
int
main()
{
      char *s=malloc(1);

      my_strcpy(s,"Hello");
      
      my_strcat(s," world");

      printf("%s\n",s);

      free(s);

      return 0;
}

Reply via email to