Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sevak

To BIG!!

This topic is 5433 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

/******************************* * CACULATOR *CREATOR:Sevak *DATE OF CREATION: 01/09/03 09:26 *DATE OF REVISON: - *FUNCTIONS: Add,Subtract,Multiply,Divide *REASON CREATED: To practice C++. *USAGE: Basic Math * ********************************/ /**Include Files**/ #include <iostream> #include <stdlib.h> /**Include Files**/ /*****Namespace****/ using namespace std; /*****Namespace****/ /***************Functions*******************/ float Add(float a,float b){return a+b;} float Subtract(float a,float b){return a-b;} float Divide(float a,float b){return a/b;} float Multiply(float a,float b){return a*b;} int Body() {//Begin Body //Body Variables short Choice; float number1,number2,result; //Body Variables while(1) {//Begin While loop 1 cout << "\n\t\t\t 4 function Caculator\n" << "\n1.Add\n2.Subtract\n3.Multiply\n4.Divide\n5.Exit" << "\nPlease choose what you want to do:"; cin >> Choice; switch(Choice) {//Begin Choice switch case 1: cout << "Enter first number to add: "; cin >> number1; cout << "Enter second number to add: "; cin >> number2; result = Add(number1,number2); cout << number1 << " + " << number2 << " = " << result << endl; break; case 2: cout << "Enter first number to Subtract: "; cin >> number1; cout << "Enter second number to Subtract: "; cin >> number2; result = Subtract(number1,number2); cout << number1 << " - " << number2 << " = " << result << endl; break; case 3: cout << "Enter first number to Mulitply: "; cin >> number1; cout << "Enter second number to Multiply: "; cin >> number2; result = Multiply(number1,number2); cout << number1 << " * " << number2 << " = " << result << endl; break; case 4: cout << "Enter first number to Divide: "; cin >> number1; cout << "Enter second number to Divide: "; cin >> number2; result = Divide(number1,number2); cout << number1 << " / " << number2 << " = " << result << endl; break; case 5: return 0; default: cout << "Error: Invalied Command\n"; break; }//End Choice switch }//End While loop 1 }//End Body /***************Functions*******************/ /***************Main*******************/ int main() {//Begin Main Body(); return 0; }//End Main /***************Main*******************/ This simple caculator program takes about 440kb. That seems pretty big. Im using DevC++. Is that normal?O ya and can someone tell me how to create one of those white boxes in a post so i can put my coding in it and it wont look so big.

Share this post


Link to post
Share on other sites
Advertisement
Do you really need #include <stdlib.h> ? that will increase the size a bit, plus it should be cstdlib if it is needed

use [] tags with source and /source in them to add code.



[edited by - quant on September 1, 2003 3:38:55 PM]

Share this post


Link to post
Share on other sites
I took out that but still its stuck on 440kb. It probably went down a few hundred bits but no kb.

Share this post


Link to post
Share on other sites
You need to turn off 'Debug Output Generating' and in the 'Linker Command Line' (orsomething like it) you need to add '-s'. Read the DevCpp FAQs or search the DevCpp forums.


[...] Here it is: [...]

Project Options ->
Parameters ->
Linker ->
Add '-s'.

&

Project Options ->
Compiler ->
1) Linker -> Generate Debugging Information = No
2) Optimization = Yes
3) Optimization -> Best Optimization = Yes

Rebuild your project.




.lick



[edited by - Pipo DeClown on September 1, 2003 3:56:04 PM]

Share this post


Link to post
Share on other sites
Did you use optimization? You are using floats which take up a little bit more. That might be why.

Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis

Share this post


Link to post
Share on other sites
#including things you don''t need doesn''t increase code size.
Switching your namespace designations doesn''t increase code size.
And of course he''s using floats. It''s a calculator.

You just need to turn on optimizations and turn off debug output.

I like pie.

Share this post


Link to post
Share on other sites
I''ve noticed that Dev-CPP files are always a little bloated. My Win32 program that doesn''t do anything is 100 kb. I really wish there was a way to get it smaller...

Share this post


Link to post
Share on other sites
quote:
Original post by Pipo DeClown
You need to turn off ''Debug Output Generating'' and in the ''Linker Command Line'' (orsomething like it) you need to add ''-s''. Read the DevCpp FAQs or search the DevCpp forums.


Ill second that.
quote:
Original post by Pipo DeClown
Guys it''s about compile/linking optimization, not code optimization.


And that!.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!