|
-
Jan 4th, 2003, 01:45 PM
#1
Thread Starter
yay gay
exe size
i did this test program and compiled it...but why da hell do it make an exe with about 500kb!??!
PHP Code:
// test1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Maths
{
public:
static void Maths::Intro()
{
cout << "You can execute up to 4 mathematical operations:\n";
cout << "\tAdd\t\t1\n";
cout << "\tSubtract\t2\n";
cout << "\tMulitply\t3\n";
cout << "\tDivide\t\t4\n\n";
cout << "Which one you want to perform?\n(Type the number of the operation)\n";
}
static int Maths::Add(int num1, int num2)
{
return num1 + num2;
}
static int Maths::Subtract(int num1, int num2)
{
return num1 - num2;
}
static int Maths::Multiply(int num1, int num2)
{
return num1 * num2;
}
static int Maths::Divide(int num1, int num2)
{
return num1 / num2;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
int res, num1, num2;
Maths::Intro();
cin >> res;
cout << "Now put the first number: ";
cin >> num1;
cout << "\nNow put the second number: ";
cin >> num2;
switch (res)
{
case 1:
cout << num1 << " + " << num2 << " = " << Maths::Add(num1, num2);
break;
case 2:
cout << num1 << " - " << num2 << " = " << Maths::Subtract(num1, num2);
break;
case 3:
cout << num1 << " * " << num2 << " = " << Maths::Multiply(num1, num2);
break;
case 4:
cout << num1 << " / " << num2 << " = " << Maths::Divide(num1, num2);
break;
default:
cout << "It wasn't possible to perform the desired operation";
}
cin >> res;
return 0;
}
\m/  \m/
-
Jan 4th, 2003, 01:50 PM
#2
Fanatic Member
If you're using VC++ 6 then you can do this:
Menu Build->Set Active Configuration
Choose Win32 Release.
The default configuration mode is debug. This means that your exe contains a lot of debug information, which is responsible for the extra k's.
-
Jan 4th, 2003, 01:52 PM
#3
Fanatic Member
Whoops, I don't hope you have this in your code: <img src="images/smilies/biggrin.gif" border="0" alt="">
-
Jan 4th, 2003, 02:10 PM
#4
Thread Starter
yay gay
actually i have...whats the prob?
jk... it was the forum whom translated that wrong lol
\m/  \m/
-
Jan 4th, 2003, 02:12 PM
#5
Thread Starter
yay gay
hmm now it got down to the 100k...but is a bit much i think...i had the idea c++ apps were smaller than vb ones!
\m/  \m/
-
Jan 4th, 2003, 04:36 PM
#6
That's the C++ iostream.
No, C++ apps are not necessarily smaller than VB apps. Especially when they are small and you link to the runtimes statically.
Static linking increases your exe size but the exe is standalone - it doesn't need any runtimes. So you have either large apps or small apps that need runtimes.
VB apps on the other hand are large AND need runtimes.
You can choose whether to link statically or dynamically to the CRT and C++ Library by going to the project options and changing C/C++ -> Code Generation -> Runtime Library.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 5th, 2003, 05:36 AM
#7
Hyperactive Member
You dont have to use iostream and fstream. I use Standard File IO and Standard Output - gives me executables in < 36 kb!
Code:
#include <iostream>
using namespace std;
Code:
#include <stdlib.h>
-
Jan 5th, 2003, 07:29 AM
#8
Yes, but the streams are easier to use and typesafe.
Not to forget that they fit more into C++ philosophy and allow you overloading the stream insertion/extraction operators.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|