I know that using C++ compilers adds some space to the size of a file. I am just wondering if the amount of variables declared in the program increases the file size. I didn't think it did, but I have a failry siple program that is 4 MB.
I know that using C++ compilers adds some space to the size of a file. I am just wondering if the amount of variables declared in the program increases the file size. I didn't think it did, but I have a failry siple program that is 4 MB.
The file size is based on your compiler's ability to optimize the code and your ability to write the code.
You need to read your compiler's docs to know its optimization capabilities.
The number of vars does not significantly increase the file size. Your choice of logic structures, e.g., if else, switch, while, for, etc., does.
hth,
If you're using MSVC try setting it to release setting rather than the default debug. That cuts the file size down dramatically. Then you can specify the optimizations too.
If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?
I used Borland C++ 5.02 to compile it. I am not sure of the exact code because I modified it a few times, and I haven't looked at it in a while.
Your variable names add nothing to the end file size. When compiled, all variables 'lose' their name.. therefore naming something 'i' instead of 'myVariableThatHoldsAValueForMyLoop' makes no difference.
But as someone else stated (did they?) that the amount of variables will.
For a large program, variable names might start getting important, but for "very simple" programs, it is usually what you link that determines the size. Try optimising your #includes and your libs.
well this program calculates the first 10,000,000 prime numbers, and I am not sure how my variables are set up