I need to know how to redirect my IDE (eclipse) to use a much more current version of MinGW. I also have evidence I believe makes the case for a problem with the current compiler.
Are you saying the code compiles with an older version of MinGW but not with a later? What is the error/problem? Make sure you include all necessary headers.
#include <iostream>
usingnamespace std;
int main()
{
int jelly_beans = 0;
for(int i=0;i<10000; ++i)
{cout<<++jelly_beans;}
return 0;
}
This does work (i var was only chang)
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
int main()
{
int jelly_beans = 0;
for(int i=0;i<1000; ++i)
{cout<<++jelly_beans;}
return 0;
}
Same behavior on both Qt, Eclipse. Works fine on IDEone -->
Given the fact that MingW is shared by both on this machine, I surmise the IDE error is in the compiler path/MInGW path.
The code compiles with older version but with crazy output, and I don't know how to get Eclipse t use the newer version of MinG. Or QT for that matter.
Well its really odd. My computer starting throwing blue screens left and right, so I reinstalled from a system image. The problem that was also manifesting in Qt cleared up; the ones in Eclipse continued despite a fresh install; that is setting the condition to 10k from 1k no output.
eclipse: after install:
works while condition <1000
1 2 3 4 5 6 7 8 9 10 11
#include<iostream>
usingnamespace std;
int main()
{
int jelly_beans(0);
for (int i(0); i<1000; ++i)
{cout<<i;}
cout<<"Jellybeans"<<endl;
}
output:
01234567891011121314151617181920212223242526272829303132333435363738394041424344454647... ad infinitum
increase i to 10000 no output
1 2 3 4 5 6 7 8 9 10 11
#include<iostream>
usingnamespace std;
int main()
{
int jelly_beans(0);
for (int i(0); i<10000; ++i)
{cout<<i;}
cout<<"Jellybeans"<<endl;
}
If the value of expression is nonzero, statement 1 is executed. If the optional else is present, statement 2 is executed if the value of expression is zero.
If expression is zero it goes down to the statement 2. If statement 2 doesn't exist and the initial expression is zero it appears the program stops at the loop and picks it up again after the loop -- looks like the code is being ignored.
Run the program again and see it just outputs statement 2. But we predicted that: expression 1 is zero and the statement is skipped and the program checks to see if there is a second statement to run, which, in this example, does.
Easy: look at the code. See what it does with manipulating flag1. Set flag1->0 and it skips the instructions and goes down to statement 2 "jump to 2nd condition". If on the other hand u increase flag1->1 or more, both statements will be executed.
#include
<iostream>
int main()
{
usingnamespace std;
int number;
cout<<"Enter number to be checked for primeness :";
cin>>number;
cout<<"you chose "<<number<<" to be checked";
cout<<endl;
int a[0];int flag1(0);
for(int x(1); x<number;++x)
{
if (flag1)
{
cout<<flag1<<endl;
cout<<x;
}
else
{
cout<<"jump to 2nd condition"<<endl;
}
//a[x] = x;
//cout<<"end of tool";
}
cout<<"flag2"<<endl;
return 0;
}
It does: I thought the "crazy" compiler was causing serious pc rot with regard to using IDE. I then came across a MS article about proper interpenetration of for-else loops and inital variable states. I learned from that and it made the problem disappear. Operator error I guess.