keep newer copy MingGW

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.
Last edited on
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.
This doesn't work (no output)

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace 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>

using namespace 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.
If you never flush the output stream why would you expect anything to be output?
Shouldn't cout automatically flush when the program ends?
> Shouldn't cout automatically flush when the program ends?

Yes. The destructor of the last instance of std::ios_base::Init flushes all standard output streams.
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>

using namespace 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>

using namespace std;

int main()
{
int jelly_beans(0);
for (int i(0); i<10000; ++i)
	{cout<<i;}
cout<<"Jellybeans"<<endl;
}

only output, loop skipped
Jellybeans

Last edited on
Maybe eclipse has some kind of limit on how long output lines can be? What happens if you separate the numbers with spaces or newlines?
Hi Peter I figured it out with some help from Microsoft article ( can u believe that).

https://msdn.microsoft.com/en-us/library/y34a3dk2.aspx

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include
<iostream>

int main()
{
using namespace 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;
}
Last edited on
But that doesn't seem to have anything to do with your original problem?
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.
Topic archived. No new replies allowed.