Question

Instead of this initial snippet:

#include <iostream>
using namespace std;

int main() 
{
    cout << "Hello world!" << endl;

    return 0;
}

I would like something like this:

#include <iostream>

int main() 
{
    return 0;
}
Était-ce utile?

La solution

Your question isn't entirely clear, so I'll give three answers.

If you're referring to what opens when you open Code::Blocks itself, go to the Settings menu, then click Environment. Make sure you're in the General Settings section of the sidebar; change On application start-up to Open blank workspace.

If you're referring to what shows up when you create a new project, @Blorgbeard's link has a (slightly dated) picture showing how to create a new project template. Set up a project the way you want it, then open the File menu and click Save project as template.

If you're referring to what shows up when you create a new file in your project, go to the Settings menu, then click Editor. Scroll to the Default code section of the sidebar; whatever you enter here will be set as the default contents for any C++ source file (or any C++ header file) you create.

Autres conseils

For c++, edit Program Files ( or where you installed it ) \ \CodeBlocks\share\CodeBlocks\templates\wizard\console\cpp\main.cpp and for c edit \CodeBlocks\share\CodeBlocks\templates\wizard\console\c\main.c

Go to the folder where Codeblocks is installed and find the templates folder.

Program Files / CodeBlocks / share / CodeBlocks / templates

You will find the console-main-c and console-main-cpp files there. Edit these files to change the default code.

If you are using Linux, you can find the default "main.cpp" file under:

/usr/share/codeblocks/templates/wizard/console/cpp/

Just make sure you edit it with an admin privilege.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top