delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | Cesar Rabak <crabak AT acm DOT org> |
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: | <WcpNc.640$zS6 DOT 86489 AT news02 DOT tsnz DOT net> <20040727070949 DOT 29244 DOT 00000306 AT mb-m19 DOT aol DOT com> <pnxNc.667$zS6 DOT 95084 AT news02 DOT tsnz DOT net> |
Mime-Version: | 1.0 |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |