How to combine to programs using a project in C++

Discussion in 'C++' started by Andres, Aug 5, 2008.

  1. Andres

    Andres New Member

    Joined:
    Jul 22, 2008
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    I created a project and added two programs to it. For some reasons it doesnt want to compile...i get this...
    multiple definition of main
    first defined here
    id returned 1 exit status
    [Built Error][Pro.exe] Error 1


    How can i fix it?
     
  2. debleena_doll2002

    debleena_doll2002 New Member

    Joined:
    Feb 5, 2008
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<stdio.h>
    
    //Enable first program
    #define run1
    //Enable second program
    //#define run2
    
    //First program
    #ifdef run1
    int main()
    {
      printf("I am from main in run1 section");
      return 0;
    }
    #endif
    
    //second Program
    #ifdef run2
    int main()
    {
      printf("I am main in run2 section");
      return;
    }
    #endif
    
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice