Date: Thu, 7 May 1998 16:37:18 +0300 (IDT) From: Eli Zaretskii To: Ville Lundberg cc: djgpp AT delorie DOT com Subject: Re: Segmentation fault in UNIX In-Reply-To: <35519D05.18BA@cc.hut.fi> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Thu, 7 May 1998, Ville Lundberg wrote: > Why does this simple piece of code cause a "Segmentation fault" in UNIX, > while it works just fine in DOS? The error occurs when the code hits the > getpass() function. Your `line' variable points to nowhere, so your program dereferences am unitilialized pointer and crashes. As to why doesn't it crash in DOS, it depends on your environment. I think if you use CWSDPMI it will crash as well, but Windows doesn't usually care if you dereference null pointers. > char *lin, *pin; Either use "char lin[80]", or allocate memory dynamically with malloc, before you call gets(lin).