|
From: Teodorescu C. <te...@xt...> - 2002-08-07 05:27:57
|
Carlos Garc=EDa del Monte wrote:
> It shall work if it compiles. But when I declare /i /like you, inside=20
> a for statement, the compiler reports error due to an old fashioned=20
> way to declare it, try to declare it before the for. But then that=20
> error should have been reported.
Be carfull of file extension like :
a.c and a.cpp
if in a i have
for (int i=3D0;i<19;i++)
{
};
if you save like a.c you are candidate for an error depends if the=20
compiler takes or not .c file like .cpp
but if you save like a.cpp your compiler always take this statement like=20
cpp
> Or substitute it by a while, and perhaps after you can restore the for=20
> and see what happens.
> On one of my recent experiments I first used a for, the program didn't=20
> run and I changed it by a while, and it worked (???????), after I used=20
> again the for and it worked (??????????!!!!!!!!!!!!!!).
> Some times the compiler behaves a little strange, it pass over lines=20
> don't executing them, or calls functions which are not called where it=20
> calls them, or makes a for or while not work although it is well=20
> written...
>
> tam...@ms... escribi=F3:
>
>> I have been tasked with a problem in my newbie manual to use a "for=20
>> loop" and to console out by 2's from 0 to 20 here's what I have done=20
>> and I was wondering 1st why it doesn't work and 2nd how do I make it=20
>> work. #include <iostream>int main()
>> {
>> // --- iterate an integer by 2
>> for (int i =3D 0; i <=3D 20; i+=3D2){
>> std::cout << i << '\n';
>>
>> }
>> // --- pause system
>> char end[5];
>> std::cin >> end; return 0;
>> } Thanks in advanceDanny
>> =20
>>
|