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.
Showing posts with label C. Show all posts
Showing posts with label C. Show all posts
Saturday, 9 April 2011
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.
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 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.
/* 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.
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.
Labels:
8.02,
bug,
builder,
C,
Code::Blocks,
command line,
compiler,
gazto,
GCC,
GNU,
linker,
output
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.
Labels:
.c,
.h,
C,
C_tutorial,
Code::Blocks,
gasto,
gazto,
IDE,
programming,
series,
video
Subscribe to:
Posts (Atom)