Results 1 to 8 of 8

Thread: exe size

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    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 num1int num2)
            {
                return 
    num1 num2;
            }

            static 
    int Maths::Subtract(int num1int num2)
            {
                return 
    num1 num2;
            }

            static 
    int Maths::Multiply(int num1int num2)
            {
                return 
    num1 num2;
            }

            static 
    int Maths::Divide(int num1int num2)
            {
                return 
    num1 num2;
            }
    };

    int _tmain(int argc_TCHARargv[])
    {
        
    int resnum1num2;
        
    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(num1num2);
            break;
        case 
    2:
            
    cout << num1 << " - " << num2 << " = " << Maths::Subtract(num1num2);
            break;
        case 
    3:
            
    cout << num1 << " * " << num2 << " = " << Maths::Multiply(num1num2);
            break;
        case 
    4:
            
    cout << num1 << " / " << num2 << " = " << Maths::Divide(num1num2);
            break;
        default:
            
    cout << "It wasn't possible to perform the desired operation";
        }

        
    cin >> res;
        
        return 
    0;

    \m/\m/

  2. #2
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    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.

  3. #3
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    Whoops, I don't hope you have this in your code: <img src="images/smilies/biggrin.gif" border="0" alt="">


  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    actually i have...whats the prob?


    jk... it was the forum whom translated that wrong lol
    \m/\m/

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    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/

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  7. #7
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    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>
    VS.NET 2003

    Need to email me?

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width