Code::Blocks Forums

User forums => Help => Topic started by: kartal on June 06, 2009, 07:07:32 am

Title: Running .c files without creating a project
Post by: kartal on June 06, 2009, 07:07:32 am
Hi


I have started learning C and I am enjoying CB quite a bit.

I am wondering that if it it possible to run compile and run .c files without creating a project?

thanks
Title: Re: Running .c files without creating a project
Post by: MortenMacFly on June 06, 2009, 07:23:01 am
I am wondering that if it it possible to run compile and run .c files without creating a project?
Yes, but with limitations. Just try!
Title: Re: Running .c files without creating a project
Post by: kartal on June 06, 2009, 07:34:34 am
MortenMacFly, how do I do it? It seems  like I need a project to be able to open and compile a file?
Title: Re: Running .c files without creating a project
Post by: Dr.Optix on June 06, 2009, 09:49:55 am
1. Open C::B
2. File->New->File
3. Select C/C++ File and do what the wizard asks you
4. Write this program:
Code
#include<stdio.h>
int main()
{
    printf("Dr.Optix :D");

    return 0;
}

5. Press F9 and all should work without problems :)
Title: Re: Running .c files without creating a project
Post by: kartal on June 06, 2009, 06:23:16 pm
Dr.Optix ,
For some reason, I cannot get it to work. It(F9) is just running previously compiled project. I have tried clean, clean workspace etc. I cannot get it to compile the currently open file that is not part of any project. Bear in mind though I do not want to delete or get rid of my open projects. I just want to be able to compile a file that is not part of any projetc, just for convenience.

Title: Re: Running .c files without creating a project
Post by: Dr.Optix on June 06, 2009, 06:46:28 pm
Tryed with multiple instance of C::B like

One where your project is open and one where you edit/compile your "lone wolf" file

EDIT:

Also you can use Ctrl+Shift+F9 to compile current file, but it just compile it, it don't run it.
Title: Re: Running .c files without creating a project
Post by: Jenna on June 06, 2009, 06:53:08 pm
Dr.Optix ,
For some reason, I cannot get it to work. It(F9) is just running previously compiled project. I have tried clean, clean workspace etc. I cannot get it to compile the currently open file that is not part of any project. Bear in mind though I do not want to delete or get rid of my open projects. I just want to be able to compile a file that is not part of any projetc, just for convenience.


The default shortcut for compile current file is "Strg+Shift+F9" (easy to see if you open the "Build" menu).
Title: Re: Running .c files without creating a project
Post by: kartal on June 06, 2009, 07:02:54 pm
I am really not sure what I am doing wrong here. The only things I can think of are, 1-user error, 2-I am using nightly.

I can compile the current file but when I click on "Run" it runs the project or tries to built the active project.
Title: Re: Running .c files without creating a project
Post by: Ceniza on June 07, 2009, 10:23:06 am
Close all your projects first (empty workspace), then try again.