|
From: Ioannis V. <no...@ho...> - 2002-08-06 12:37:34
|
<http://run.to/noicys>=20 -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Carlos Garc?a del Monte Sent: Tuesday, August 06, 2002 3:13 PM To: dev-cpp-users-list Subject: Re: [Dev-C++] iterating by 2 It shall work if it compiles. But when I declare i like you, inside a for statement, the compiler reports error due to an old fashioned way to declare it, try to declare it before the for.=20 =20 ? What compiler do you have? =20 But then that error should have been reported.=20 Or substitute it by a while, and perhaps after you can restore the for and see what happens.=20 On one of my recent experiments I first used a for, the program didn't run and I changed it by a while, and it worked (???????), after I used again the for and it worked (??????????!!!!!!!!!!!!!!). =20 =20 Obviously the first time you made a syntax error. The definition inside a for loop is valid ANSI C++ (we are talking about C++ here). =20 =20 Some times the compiler behaves a little strange, it pass over lines don't executing them, or calls functions which are not called where it calls them, or makes a for or while not work although it is well written... =20 =20 Your compiler needs psychiatric evaluation. :) =20 tam...@ms... escribi=F3:=20 I have been tasked with a problem in my newbie manual to use a "for loop" and to console out by 2's from 0 to 20 here's what I have done and I was wondering 1st why it doesn't work and 2nd how do I make it work. #include <iostream>int main()=20 {=20 // --- iterate an integer by 2=20 for (int i =3D 0; i <=3D 20; i+=3D2){=20 std::cout << i << '\n';=20 }=20 // --- pause system=20 char end[5];=20 std::cin >> end; return 0;=20 } Thanks in advanceDanny =20 =20 =20 Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net <http://www.noicys.cjb.net/>=20 * Alternative URL: http://run.to/noicys =20 |