User forums > Using Code::Blocks

Learning C++ Main.cpp

(1/1)

superjacent:
Hope this is the right forum.

I'm learning C++ and looking at a few ide's.   I'm typing numerous examples from a book, all simple stuff.   My question is, I can't seem to change the filename "main.cpp".   Is it the case that for each new program (or Hello World type example) they have to be in their own directory.   They are only simple console apps.   All this simple stuff I'm just wanting to keep them contained in the one directory (my directories for training purposes named Chapter01, 02 etc.)

Any help would be appreciated.

Steven Taylor
Melbourne, Australia.

mike:
I didn't really follow your question, but if all your files (for some reason) must be called "main.cpp", then obviously you shall spread them into different directories. It is probably easier, though, to call them "lesson01.cpp", "lesson02.cpp", etc.

mandrav:
I guess superjacent meant that when he creates a new project (from the templates), it always contains a file called main.cpp. This is designed like that because, usually, each project lives in its own folder.

The only workaround is to create a new empty project and then create a new file with the name you choose and add it to the project. Just remember to go to project properties and change its type to console application (IIRC defaults to GUI application).

HTH,
Yiannis.

Anonymous:
When you create a new project using templates, at least one starter file will be auto created.  Just remove these file(s) using the "Project" menu and then remove them physically from disk.  Add your files to the project and then save it once and you are done.

Anonymous:

--- Quote from: Anonymous ---When you create a new project using templates, at least one starter file will be auto created.  Just remove these file(s) using the "Project" menu and then remove them physically from disk.  Add your files to the project and then save it once and you are done.
--- End quote ---
Thanks all.

Navigation

[0] Message Index

Go to full version