Hello, I'm new to C eclipse. I use eclipse for java programs and found it very easy to create new classes within one project but now working on C. I would like to know how do I create multiple main programs within one project just as I could while running java. I have a C book and use youtube and I'm always creating new programs but would like to keep all organized under one C project. If I try to run a second main program I will get an error such as multiple definition of main. I guess I can create a new project for every tutorial/chapter but that option doesn't seem appropriate so I'd like to keep my projects organized just as could when working with Java.

Why do you need mpultiple main-function?? it's not possible in c to have more than 1 main-function. you could use preprocessor directives like "#ifdef" to compile just one main-function at the time. an switch to another main-funtion by changing the condition.
But its not a good programing style.

I guess I can create a new project for every tutorial/chapter but that option doesn't seem appropriate so I'd like to keep my projects organized just as could when working with Java.

Internal CDT builder is primitive and can't do what you want because one project can have only one target. But you can always switch to external building via makefile or custom commands. So it is possible for example to use a single makefile with several different targets (executables). A convenient way to generate such makefile can be using CMake.

Mackie M schrieb:
> Hello, I'm new to C eclipse. I use eclipse for java programs and found
> it very easy to create new classes within one project but now working on
> C. I would like to know how do I create multiple main programs within
> one project just as I could while running java. I have a C book and use
> youtube and I'm always creating new programs but would like to keep all
> organized under one C project. If I try to run a second main program I
> will get an error such as multiple definition of main. I guess I can
> create a new project for every tutorial/chapter but that option doesn't
> seem appropriate so I'd like to keep my projects organized just as could
> when working with Java.
> Any help would be highly appreciated.

Why not renaming them? Like main_test1(), main_test2() and calling them
from a single main, maybe using a menu. The menu could wrap the
funktions and provide an input of parameters, also telling about return
value.

I guess to be more specific I should add more details. While using java I could create a new class every time I started a new tutorial and ran each of them separately UNDER the same project. I would like to implement the same when working with C. I've done some research and it seems the only option is to create a targeted makefile with target files of its own. It seems C language is much older than expected. Or the last thing to do is to simply run every single tutorial/program under the main program which means I would not be able to save any other programs except for main which will be used to run the program.