X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Cesar Rabak Newsgroups: comp.os.msdos.djgpp Subject: Re: assembly code of the "strange error" - program Date: Tue, 27 Jul 2004 16:48:55 -0300 Lines: 36 Message-ID: <4106B1A7.1030602@acm.org> References: <20040727070949 DOT 29244 DOT 00000306 AT mb-m19 DOT aol DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de m3UPsmT0wh5fhrvrfwHJog6dqG3DpX6CVxBFKOX9yC1280dTo= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: pt-br, pt To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Paul Wilkins escreveu: > Sterten wrote: [snipped] >> >Now check this out. >> > >> >int U[99]; memset(U, 4, sizeof(U)); >> > >> >memset fills the memory locations used by U with the value 4. >> >> I prefer: for(i=0;i<99;i++)U[i]=4; > > > And later on when you change the array size and forget to change the > code you will have nasty problems. > To avoid this mistake (really common and nasty), a good practice is to use macros defining the sizes: #define SIZE 99 . . . int U[SIZE]; . . . for(i=0; i< SIZE; i++) U[i]=4; HTH -- Cesar Rabak