Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   How to combine to programs using a project in C++ (http://www.go4expert.com/forums/combine-programs-using-project-cpp-t12725/)

Andres 5Aug2008 23:04

How to combine to programs using a project in C++
 
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?

debleena_doll2002 7Aug2008 10:07

Re: How to combine to programs using a project in C++
 
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



All times are GMT +5.5. The time now is 21:25.