ccodeblocksprojects

How to compile and run a C file in CodeBlocks which is outside a project?


I have opened a project in CodeBlocks, which builds and runs successfully. Now if I open another C file in the IDE, the build and run command will act on the existing open project and not on the new C file. If there were multiple projects, we can switch between them using " activate project" . But what if there is one active project and another C file outside the project. How to complile and run the C file then ?


Solution

    1. Under the Projects tab on the left, right- click on your project and click Close project. Do this for all projects that are open.

    2. Now, if your C file is open, just press F9 to compile and run your program.

    It is easy to compile and run a single C file in Code::Blocks:

    1. To create the file, click on File -> New -> Empty file
    2. After typing the code, save it with .c extension.
    3. Press F9 to compile and run the program.