RE: So weird!

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 27 Jul 2010 03:05:52 -0700

Hi,
That's right - if there is no matching braces, the compiler would be
confused about subsequent lines of code from your program. As for putting a
comment after that right brace, it is actually optional, but I think the
author recommends it for style and integrity.
Cheers,
Joseph

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
Sent: Tuesday, July 27, 2010 2:04 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: So weird!

Well, according to our book, the } //end while is essential. Otherwise the
braces don't match and we get compilation syntax errors. The / / end while
is only a comment to the programmer to say hey I've just completed my while
statement.
but the right brace is crucial, according to Diane Zak. I am programming
using the  c plus plus.


On Jul 27, 2010, at 4:52 AM, Delaunay Christophe wrote:

> Hi Jes,
> Sorry. I can't really figure out what your problem is. However, by
> reading the piece of pseudo-code you wrote, I noticed that braces are
> not balanced.
> 
> The exact syntax of a do ... while statement is
> 
> do { block_of_code; } chile ( expression );
> 
> There should not be a closing brace after the "while (expression )".
> 
> So, if I use this scheme to rewrite your sample, I would have written:
> 
> do
> {
>       Block 1 of code;
>       Block 2 of code;
> }
> while ( (something != this) && (something != that) );
> return 0;
> } // end of main function
> 
> In other words, you can notice that I did not report the "} //end while"
> line sinc it is the cause of a compilation error.
> HTH. Have a nice day. Chris D
> 
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
> Sent: mardi 27 juillet 2010 10:32
> To: programmingblind@xxxxxxxxxxxxx
> Subject: So weird!
> 
> I notice that sometimes when I am coding an algorithm, I'll put in a
> block of code that works rock solid every time it is executed. For
> example:
> do
> {
> Block 1 of code
> cblock 2 of code;
> 
> }
> while (something != this && something != 'that');
> 
> } //end while
> return 0;
> } //end of main function
> Then, for whatever reason, I'll type that exact set of instructions
> somewhere else, by hand, and it won't compile, but when I select the
> rock solid portion of code and copy it, the program compiles just fine.
> How strange. Is this just me? Sorry if I am confusing all you peepers to
> death!
> Jes
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
> 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.441 / Virus Database: 271.1.1/3030 - Release Date: 07/26/10
18:34:00

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: