TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: Bo Simonsen
from: William McBrine
date: 2003-08-02 01:43:38
subject: Re: This always drives me cr

-=> Bo Simonsen wrote to William McBrine <=-

 WM>  for (int x = 0; x < 100; x++)

 BS> That's not ANSI C/C++, it should be:
 BS> int x;
 BS> for(x=0; x < 100; x++)

It's not ANSI C, but it _is_ standard C++. Since this is the C++ echo, I
thought that would be OK. :-) Admittedly, the rest of the message would
apply just as well to C as to C++, if one replaced "new" with malloc(). I
almost referred Neil to the K & R book, which devotes a chapter to pointers
and arrays.

You're probably thinking of the change in scope specified in ANSI C++,
where the variable now goes out of scope at the end of the loop. But it's
still valid _within_ the loop, as I used it.

 BS> I know borland c++ compile it, but gcc/g++ doesn't.

Yes, it does. (More precisely: g++ does; gcc doesn't. That is to say, it
works in C++ mode, and not in C mode.)

... Blimey, this redistribution of wealth is trickier than I thought!
--- MultiMail/Linux v0.45
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
SEEN-BY: 633/267 270
@PATH: 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.