Friday 29 April 2011

14 · Functions implementations

2 Functions are prototyped, defined and called: print_always_7() which is a function used for its side-effects and sum() which is a pure function(used for the return value)

Wednesday 20 April 2011

Study skills for programmers

Computer skills are little without the actual theory and practice of the methods and methodology used to arrive at the knowledge.

People are way too much focused on trivial circumstances when learning, while they should be focused more on how to learn and find information, rather than retaining the most of information as possible(as it has been for experts before the advent of computers and internet).

These video series I am planning to create, will treat subjects like creating tables and diagrams in big glyphs so that one can attach it to the wall in front of the computer, so that when you need a reference fast, you don't have to do other tasks but to slightly turn your head and watch what the diagram suggests; or finding out when you program what things went wrong with your experimentation, you screen capture what you did, so that when you re-encounter a problem that you think is related to a previously encountered problem, you just refer to that video of the screen capture and recall what actually happened. There are many more study skills that are simple but really help a lot in computer programming, and many other subject matters as well.

Saturday 9 April 2011

Functions in pseudo-code

We create function prototypes, definitions, and calls, all in pseudo-code. In this way we understand the basic skeleton of single filed C source code. Parameters(for prototypes and definitions) and arguments(for calls) are succinctly explained. The idea of return types(or the lack thereof, using void) is examined, and the reason why functions exist in code is also explained.

Span Of Statements

In this video tutorial, we check the way the C compiler treats the different tokens, by actually dividing a big line of code into two smaller lines, each time separating the lines in different spots, so as to understand better how the C compiler interprets the different divisions.

Line by line explanation

In this succinct tutorial, we review what has been taught before, but go little-by-little, through each line explaining in more detail the program that we have been creating.

If statement

The if statement serves for bifurcating the execution of the instructions within the program.
if the condition of the if statement results in a boolean true(non-zero), the if code block executes, otherwise(boolean false, AKA zero) it does not.

We build and run the program several times, in each occasion modifying the resulting if conditional expression, so as to check how the program behaves with different conditions.

Comment usage

We realize that Code::Blocks has line numbering, text colouring, and easy text editing capabilities, therefore, edit.com is avoided. The two types of C comments are explored:

/* comments here */ is the C style comment, it lasts for as many lines as the delimiters indicate.

// C++ style comment is the C++ style comment, it lasts up until the end of that line.

Comments are used documentation and explanation purposes. Obvious beginner explanations must be skipped for real world programs. Only in educational material will you find comments being used as obvious explanations.

Variables definitions

We create our first variable in the program. the assignment operator = is discovered. The printf function from the stdio.h header is succinctly explained, along with the %d format specifier. Three programs are used to edit our code: edit.com, notepad.exe, and Code::Blocks, just to clarify that any text editor will suffice.

Friday 8 April 2011

Batch commands

We change the location of some files from MinGW_exercises to MinGW_exercise\01 . Batch commands are used from the terminal in order to perform these operations. Batch scripting is a powerful alternative to hard disk explorers, if saved on a script file, it allows the automatic execution of certain housekeeping tasks.

First C program built (from terminal)

We prepare the directory tree so that we have a well sorted hierarchy. In that way we are better organized to build, whether we use the Code::Blocks IDE, or directly from the command line. Some batch commands (like tree /f ) are shown. We finally build code from the terminal so as to provide another way to build our programs. This is the Unix way of building a C source file.

Code::Blocks setup and test

We correct the options at the Code::Blocks building properties, we change the link tool place holder: instead of mingw-g++, we point to the executable mingw-gcc, which serves as a compiler, linker and preprocessor program. We test the project with which we previously had difficulty building, this time succeeding in showing no errors and outputting to the command prompt.

Code::Blocks setup

The Code::Blocks is set-up so that we can use the MinGW set of utilities for compilation. C/C++( .c , .h , .cpp , .cc , .C , .H , .CPP , .CC , etc.) file extensions are associated with Code::Blocks. The first C project is tried out using the Code::Blocks project templates. There's a bug in Code::Blocks that is fixed in later versions, but for this version I show you how to fix it in the next video in the series.

Code::Blocks download

We go through a series of steps in order to download the IDE that we will be using in some video tutorials: Code::Blocks .

MinGW setup on Windows XP

So the download has finished, we need to check that the command to compile (gcc) is found by the Windows command prompt. For that we add to the PATH environment variable :
;C\mingw\bin .
We finally test MinGW's GCC from the command line:
gcc --version


Thursday 20 January 2011

Downloading MinGW

In this video I show you how to install with the automated installer, the MinGW set of tool we will be using to create(build) console programs.

Console programs are programs that run in the console(AKA terminal, shell, command line, or command prompt, each having slightly different meanings).

We check the check boxes to the options required:
  • MinGW base tools
  • MinGW Make.

C console programming.

I will start to upload the video of C console programming.

It will cover all the basic topics to get any person with a minimum knowledge of computers to begin their quest for C programming.

Be warned. The dialogue is very heavy in technical language and runs much faster than usual "beginner style" video series.

I will include a "study skill" mini-video series to help you out in taking the maximum advantage out of this and other video series.

My recommendation is to watch the whole video series from finish to start, just to get acquainted with certain terminology, pacing, and interactions within the computer environment.

Then in the second run(second time you watch the video series), you go ahead and follow step by step(by pausing the video when necessary) the actions being shown in the video. Gradually, you will build small code snippets, and applications, that will give you invaluable insight into how C works from the theoretical and practical viewpoint.


This should set anyone with interests in game development , up and running.