User forums > Using Code::Blocks

Single source, without a project file?

(1/3) > >>

DarkStar:
I am learning C++ and, for now, I am only making programs with one source file.  Is there any why to use Code::Blocks with a single source files without creating project files as well?

Or are projects so important in larger programs that I should learn how to use them now?

280Z28:
You can create an empty project from the Project menu, and it's very easy to add just that one source file to it.

I suggest you learn how to do that since it's not very hard at all, and you'll get the full features of the editor (debugger, compile options, etc) if you do.

Michael:
I agree with 280Z28. It would be better to learn since the beginning to use projects, even if they have just 1 file. When I have begun to study programming, we just used a text editor and command-line compiler (under UNIX). This was not very comfortable (e.g., debug). Later, I had to use an IDE for a larger project with several projects and a workspace :D. And I have lost precious time to learn about projects and workspaces stuff and make me accustomed to use them.

Michael
 

RKCole:
Hello, DarkStar.

I concur with what 280Z28 said.

When I was in college, my C++ professor only had the class create single source files for each assignment.  I've tested plenty of compilers, and it seems that Visual C++ would completely comply with doing this.  Later I learned the importance of projects.  Things seem to work a lot better through the creation of projects as well.

You can create a project via New->Project and then just make sure you are creating a Console Application (unless you are working on GUI Application projects) and that the file(s) options has C++ source as the selected option.  This should already create a "main.cpp" file in the project for you to begin working with.

From what I've learned through working with compilers is to make sure that "using namespace std;" is included before your "main" function so you can use "cout", "cin", and others without adding "std::".

The good thing about a project is that if you need to add extra header files and such, you can add them to the project so that everything for your application is bundled together in one place.

Although this post has become rather lengthy (I apologize for this), I hope that I've been of some help.

Please take care.

280Z28:
I also suggest learning how to program without the using directive. It is bad practice to use it, and stops the whole reason namespaces were added to the language in the first place. The core code::blocks code is written without ever using it. :)

Navigation

[0] Message Index

[#] Next page

Go to full version