Date: Thu, 14 Nov 1996 15:33:08 -0200 Message-Id: <1.5.4.16.19961114132000.29cf1b84@dmeasc.rc.ipt.br> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Eli Zaretskii , Ole Winther From: Cesar Scarpini Rabak Subject: Re: How assign to NULL POINTER Cc: djgpp AT delorie DOT com At 17:52 13/11/96 +0200, Eli Zaretskii wrote: > >On Wed, 13 Nov 1996, Ole Winther wrote: > >> I really dont know how I can assign value's to the NULL pointer, can someone >> describe how this can be done? > >The most frequent case is when you declare a pointer which is a global >variable (and is therefore initialized to zero even if you didn't give it >any value), then use it before assigning any value to it. Example: > > char *ptr; /* will be initialized to zero by the linker */ > > void myfunc(void) > { > char c = *ptr; /* this will crash your program under DJGPP */ > } Eli, this code fragment compiled w/DJGPP (albeit replacing myfunc by main straight) runs w/o problems! I'm afraid that only assignments are forbidden, dereferencing (though I agree that point to a coding error as well are allowed). [snipped] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cesar Scarpini Rabak E-mail: csrabak AT ipt DOT br DME/ASC Phone: 55-11-268-35221Ext.350 IPT - Instituto de Pesquisas Tecnologicas Fax: 55-11-268-5996 Av. Prof. Almeida Prado, 532. Sao Paulo - SP 05508-901 BRAZIL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~