Question:
Do I need a better compiler?
superfly
2012-04-25 13:12:06 UTC
I'm trying print out all of the values in the array I created. But I can't find an online compiler that can print out all 40,000 values. I've already tried Codepad.org and it wont print it all out. Is it just my source file or the compiler? If anyone could tell me of a free compiler for C++ that could print out all of the values, then I would really appreciate it.

#include

int main(){

int array[200][200], r, c, x=0;

for (r=0; r < 200; r++) {
for (c=0; c < 200; c++){
array[r][c] = x;
cout << x << " ";
x++;
}
cout << endl;
}


return 0;
}
Three answers:
SteveO
2012-04-25 13:24:30 UTC
Most compilers for C++ are free, but they aren't online at all. You can download and install Visual C++ Express, and that comes with the free Microsoft C++ compiler that is really good for Windows; you can run GCC or Clang (I prefer GCC) through MinGW on WIndows, or it runs natively on OS X and Linux. Compilers start having issues when they being compiling over the internet due to the fact that compiling is a very processor intensive process.
husoski
2012-04-25 21:01:19 UTC
The source file is fine. I see that CodePad.org reports a timeout. I'll guess that the real problem is the volume of output because it runs all 200 lines when I add an "if (c < 10) " prefix in front of the cout line to print only the first 10 items on a line.



If you are working on a computer that you can install software on, the GNU C and C++ compilers are excellent, and about the most free piece of software on the planet. There's a port of these, plus related tools, for just about every operating system that has any sort of C++ compiler at all.



For Windows, the MinGW port of GNU GCC/G++ and the Code::Blocks IDE make a decent development system. Code::Blocks is available on Linux, Unix and MacOS as well. Both GCC and Code::Blocks are open source.



Also, for Windows *only*, you can download a free-to-use Visual C++ Express edition from Microsoft. That gives you a C and C++ compiler, plus and editor and debugger.
2012-04-25 20:16:20 UTC
Why not use a real compiler? Just use gcc


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...