Search code examples
cprogram-entry-pointclion

What is the directory structure of a C Program like?


I am starting out C programming and I could not find the answer to this anywhere.

When I run a ".c" file from my C project's folder, it only runs the "main.c" file, ignoring any other ".c" source files within the project's folder. So, am I correct in understanding that I can only have one source file per project, that's being run while all the others are files that are only called (i.e. #included) by that primary source file, "main.c"? (Similar to libraries/modules in Python)

FYI, I am using CLion, if this makes any difference.

Thanks for the help.


Solution

  • CLion uses CMake, you'll find a CMakeLists.txt file in your project. Any additional source files should be added (manually) to the command add_executable(main main.c other_source.c yet_another_source.c). Notice these are space separated. You can have as many source files as you want!