Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops |
| Date | 2016-12-08 08:23 +1300 |
| Message-ID | <ear5trF5s31U1@mid.individual.net> (permalink) |
| References | <f59dc04a-dbf6-4012-a97b-13d3ef9909a0@googlegroups.com> <9a9287d4-63ef-4f69-af18-dabb00ed7e67@googlegroups.com> |
On 12/ 6/16 07:43 AM, John Bode wrote: > > The directive > > #define INITIAL_BALANCE 100.0 > > creates the *macro* INITIAL_BALANCE; when your source code is run through > the preprocessor, all instances of the text INITIAL_BALANCE will be > replaced with the text 100.0 before the code is fed to the compiler > proper. So after preprocessing, the line > > value[i] = INITIAL_BALANCE; > > becomes > > value[i] = 100.0; > > The author is basically using the macro as a symbolic constant for > the value 100.0. This serves several purposes: In this case all of these would be better served with a const float rather than a macro. > 1. Ease of maintenance - if you want to change the initial balance for > each value[i] from 100.0 to some other value, you only have to change > it in that one place, as opposed to changing multiple occurrences of > 100.0. This especially saves your bacon if you're using a naked 100.0 > for something *other* than your initial balance. > > 2. Guard against typos - the compiler isn't psychic; if I type 10.0 when I > meant 100.0, the compiler can't tell me I've goofed up (from its > perspective, both values are equally valid in the same context). If I > use the symbolic constant, I'll always get the right value. And if I > misspell the symbolic constant name, the compiler will yell at me. -- Ian
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Potomac <ravine557@gmail.com> - 2016-12-05 06:32 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-05 08:34 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-05 15:43 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-05 10:41 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-05 15:37 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops John Bode <jfbode1029@gmail.com> - 2016-12-05 10:43 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops potomac <ravine557@gmail.com> - 2016-12-07 01:13 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-07 10:55 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Philip Lantz <prl@canterey.us> - 2016-12-07 20:34 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-08 11:08 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ian Collins <ian-news@hotmail.com> - 2016-12-08 08:23 +1300
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops potomac <ravine557@gmail.com> - 2016-12-07 01:07 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-07 08:46 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 16:23 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops potomac <ravine557@gmail.com> - 2016-12-07 01:12 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-07 08:49 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops John Bode <jfbode1029@gmail.com> - 2016-12-07 15:07 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops potomac <ravine557@gmail.com> - 2016-12-07 03:46 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-07 11:59 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 12:05 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Keith Thompson <kst-u@mib.org> - 2016-12-07 09:40 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-07 15:13 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 20:24 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-07 16:28 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 21:48 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-07 17:02 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 22:19 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-07 17:27 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 22:51 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-08 09:10 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-08 14:13 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops David Brown <david.brown@hesbynett.no> - 2016-12-08 15:57 +0100
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ian Collins <ian-news@hotmail.com> - 2016-12-08 18:02 +1300
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Keith Thompson <kst-u@mib.org> - 2016-12-08 08:48 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-07 15:33 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-08 09:13 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-08 14:22 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops David Brown <david.brown@hesbynett.no> - 2016-12-08 16:03 +0100
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-08 10:44 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-08 15:48 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-08 21:41 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-08 16:16 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-08 21:47 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-08 20:16 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops David Brown <david.brown@hesbynett.no> - 2016-12-09 11:19 +0100
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops supercat@casperkitty.com - 2016-12-09 08:00 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-13 13:10 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-13 13:55 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-15 01:13 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-15 07:02 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-15 19:56 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops supercat@casperkitty.com - 2016-12-18 10:00 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops supercat@casperkitty.com - 2016-12-14 11:45 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Keith Thompson <kst-u@mib.org> - 2016-12-14 12:14 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-15 01:24 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops supercat@casperkitty.com - 2016-12-15 08:02 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Keith Thompson <kst-u@mib.org> - 2016-12-15 12:10 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Philip Lantz <prl@canterey.us> - 2016-12-16 20:00 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 11:05 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-09 16:21 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-09 13:10 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 23:44 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops supercat@casperkitty.com - 2016-12-10 10:18 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-11 16:18 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-09 08:26 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 11:15 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-09 16:31 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 23:47 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-11 16:05 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-11 16:21 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-11 23:15 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-11 18:57 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-12 00:05 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-11 21:09 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-12 08:25 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-10 07:59 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-08 13:51 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-08 13:34 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-08 21:52 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-08 19:33 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 11:20 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops jameskuyper@verizon.net - 2016-12-09 13:28 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 23:51 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-09 16:46 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-09 13:55 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 20:17 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Keith Thompson <kst-u@mib.org> - 2016-12-07 12:23 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops twalker470@googlemail.com - 2016-12-07 05:50 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-07 08:55 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-07 16:23 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-07 10:56 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops potomac <ravine557@gmail.com> - 2016-12-07 04:14 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Barry Schwarz <schwarzb@dqel.com> - 2016-12-07 11:03 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops John Bode <jfbode1029@gmail.com> - 2016-12-09 08:06 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Keith Thompson <kst-u@mib.org> - 2016-12-09 09:23 -0800
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-09 17:38 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-09 14:01 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Richard Heathfield <rjh@cpax.org.uk> - 2016-12-09 19:09 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-09 12:38 -0700
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-10 00:08 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-10 00:16 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-09 23:59 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-10 11:51 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-11 16:22 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-11 21:52 +0000
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-11 22:32 -0500
Re: Stumped on the role of a particular statement in a program with Arrays & Nested For Loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-12 04:18 +0000
csiph-web