0

To All IT Gurus,

I am trying to execute 2 .C files in one project in Eclipse. I get error. So, for example, Let us say I have this below code.

Both files 1 and 2 are in the same project First C Project, Is this allowed.??

Project Name - First_C_Project

File 1 = Example.C

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main(void) {


printf ("C Programming, This is my First C Program");

return EXIT_SUCCESS;
}


File 2: TestProgram.C


#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main(void) {


printf ("This is a TEST C Program, Check it out. ");

return 0;
}

I created a new project with a File 2 C file. And that works. But why can't I put the 2 C files work within the same First_C_Project project ???

Master Yoda
  • 23
  • 1
  • 9

1 Answers1

0

The problem is not that you have 2 c files, but that you have 2 "main" functions.

If you want to have more than one main, look here:

Eclipse CDT : How to manage multiple main() functions in a single C++ project?

If you don't need two main functions, simply comment/rename/delete the on you are not using.

Community
  • 1
  • 1
Elad Weiss
  • 3,662
  • 3
  • 22
  • 50
  • Okay, thank u. So, If I want to execute my File #2 hello world program. How can I do so without the main function and still have both c files in one project.? Hope I am making sense. – Master Yoda Nov 20 '16 at 08:14