Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!newspump.sol.net!posts.news.megabitz.net!nnrp3-asbnva.megabitz.net!not-for-mail From: James Kuyper Newsgroups: comp.lang.c.moderated Subject: Re: why do some writers declare and define variables separately Date: Tue, 8 Oct 2013 16:38:14 -0500 (CDT) Organization: A noiseless patient Spider Sender: clcm@herd.plethora.net Approved: clc@plethora.net Message-ID: References: User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 Return-Path: X-Original-to: clcm@plethora.net X-Auth-sender: U2FsdGVkX1+te+hoc+ryMzzzecEk2vRHUqnQW+IeFv1yxMdScjGFCQ== Cancel-Lock: sha1:n8Cr8SXbppc55fT5MJxgWix6Yg8= In-Reply-to: Content-Type: text/plain; charset=UTF-8 Mime-Version: 1.0 Delivered-To: clcm@localhost.plethora.net Content-Transfer-encoding: 7bit Lines: 18 NNTP-Posting-Date: 08 Oct 2013 21:38:14 GMT NNTP-Posting-Host: 4efdc93b.news.megabitz.net X-Trace: DXC=G_n^CKP9L3]ZjXXX44iW]Z><6FU_Q:4mR^W\Y;gN2lO]Y;Q@mP3hlWQhA>>DLi;CSR7d@DE\31QYUe4?]5YdC I don't really know, and I am sure there is a good explanation for it. But from my own coding experience, I prefer to initialize variables when I declare them because if you don't, it may be some random number and you could use it and not get an error that its being used. I prefer to leave variables uninitialized if I cannot initialize them with the value they're supposed to have the next time their value is read. That's because any decent compiler will give you a warning if its analysis of the code flow suggests that there's a possibility of the value of that variable being read before it gets written. Initializing a variable with a value that's not actually intended to be used turns off that warning, because the compiler doesn't know that you don't intend it to be used. -- James Kuyper -- comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must have an appropriate newsgroups line in your header for your mail to be seen, or the newsgroup name in square brackets in the subject line. Sorry.