www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/26/09:00:17

From: "Sergey Kovalev" <kos AT kbtem DOT by>
Newsgroups: comp.os.msdos.djgpp
Subject: Why so?
Date: Thu, 26 Jul 2001 15:53:34 +0300
Lines: 37
Message-ID: <9jp3tu$vb6c$1@ID-89475.news.dfncis.de>
NNTP-Posting-Host: 193.232.250.249
X-Trace: fu-berlin.de 996152070 1027276 193.232.250.249 (16 [89475])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all!

I have a code:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

int main()
{
  char *str;
  str=(char*)malloc(10);
  clrscr();
  str="01234";
  puts(str);
  printf("%s\n",str);
  strcat(str,"567");
  puts(str);
  printf("%s\n",str);
  return 1;
}

Why this code produces following results?
01234
01234
01234567
67

Other compilers give me:
01234
01234
01234567
01234567



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019