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


//  char *strcat(char *s1, const char *s2);
//  appendes contents of string s2 to s1.  Returns s1


int main()
{
   char* str1;
   char* str2;
   char* str3;
   int x=8;

   while (1)
   {
     str1 = (char*) malloc ( sizeof(char) * 10000000 );
     if (str1 == NULL) {
       printf("Malloc 1 error.....\n");
       break;
     }
     str2 = (char*) malloc ( sizeof(char) * 10000000 );
     if (str2 == NULL) {
       printf("Malloc 2 error.....\n");
       break;
     }
     str3 = (char*) malloc ( sizeof(char) * 10000000 );
//To cause a seg fault so you can play with gdb uncomment the following:
//     str1 = (char *)&x;
     if (str3 == NULL) {
       printf("Malloc 3 error.....\n");
       break;
     }
   
   strcpy(str1, "abc.....................");
   strcpy(str2, "defffffffffffffffffffffF");

    str3 = strcat(str1, str2);
   printf ("str1: %s, str2: %s, str3: %s \n", str1, str2, str3 );

   free(str1);
   free(str2);
   free(str3);
   
  }
}
