Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ukma!uflorida!haven!adm!news From: hsw@sparta.com (Howard Weiss) Newsgroups: comp.unix.questions Subject: Strcpy on SysV vs. BSD. Message-ID: <24351@adm.BRL.MIL> Date: 31 Aug 90 12:46:36 GMT Sender: news@adm.BRL.MIL Lines: 31 I've run into an interesting problem trying to use strcpy on a i386 machine running Interactive 386/ix (SysV 3.2). At first I thought the library routine for strcpy was blown away, but when I substituted my own string copy routine and got the same results (a core dump), I knew somthing strange was going on. Here is a short C program that demonstrates the problem: main(){ char *TTx = "/dev/"; char tty[10]; /* works on both SysV and BSD */ /* char *tty; /* works only on BSD */ strcpy(tty,TTx); printf("what's in tty now is %s\n",tty); } When I tried using the above program on SysV with the 'char *tty;' declaration, it compiles fine, but core dumps when run. The same thing occurs if I substitute 'while (*tty++ = *TTx++)' in place of the library strcpy. Yet, the 'char *tty' compiles and runs fine on BSD! To get this to work on SysV, I used the 'char tty[10]' declaration. Any words of wisdom as to why this is the case would be appreciated! I've worked on UNIX systems since V6 (in 1976) and I've never seen this before. Thanks, Howard Weiss Sparta,Inc. Columbia, Md. 21046 hsw@sparta.com