For 2021 - online Python 3 training - see ((here)).
Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.
Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
C and C based languages module C205
Exercises, examples and other material relating to training module C205. This topic is presented on public courses Learning to Program in C
, Learning to program in C and C++
, Programming in C
, C and C++ Programming
, Learning to program in C and C++
, C and C++ Programming
If you want to hold a who table of different pieces
of information under a single variable name, you can use
an array. This module deals with the declaration of arrays
in C, and how you write programs that will step through and
handle each element of the array in turn without having to
|Articles and tips on this subject||updated|
|4566||C - why is slow to write and debug) but fast to run?|
I often say on my courses that you can write code in a morning in Perl, Python or Ruby that would tae a week in C. How come, and why would anyone use C these days?
Firstly, C is the underlying language on which others are built. We need it there in the background, even if we don't (ourselves) code ...
|4338||Passing arrays into functions in C|
When passing arrays into functions in C, you can specify just the array name and C will pass in a pointer to the first element of the array (i.e. &abc is the same as saying just abc ). Within your functions, you can then use array style notation with square brackets, or pointers.
There's an ...
|3245||Collections in C and C++ - arrays, vectors and heap memory blocks|
If you want to hold multiple values within a table in a program, you'll want to use some form of collection or table - and in many languages including C++ and C, the most straightforward type of collection is an array. An array occupies sequential locations in the computer's memory when your program ...
|3144||Setting up arrays in C - fixed size at compile time, or dynamic|
You can store a whole series of data values of the same type in an array in C.
The easiest way to declare an array is something like:
and that will give you an array of 20 elements - which you can refer to as elements number 0 to 19, so:
history = 1234;
|3121||New year, new C Course|
Well - not completely a new course. New delegates, and lots of new examples written for them during the first day to that they can see not only WHAT work but also HOW the design of what works is put together during the day. Click on the individual source code examples, and you'll find programs to ...
|3118||Arrays of arrays - or 2D arrays. How to program tables.|
It's shorthand when you're learning a new programming language to ask "how does it handle multiple dimension arrays" ... but in practise very few languages actually support true multidimensional arrays these days, and in those which do you might be well advised to use an alternative that's more flexible.
|2840||Just pass a pointer - do not duplicate the data|
When you want to pass a big bundle of data - such as an array - into a function, it's far more efficient to pass in just a single value in the form of a pointer to the array. That's the address in memory at which the array starts and that single value can provide the key to all the data without havig ...
|2002||New C Examples - pointers, realloc, structs and more|
Every time I program in C, I marvel at how clever the language is ... yet at the same time I curse some of the devices that are used to perform certain actions, which make the code that much more of a 'puzzle' to right.
I've finished a 2 day C Programming course today ... and written a whole raft ...
|1614||When an array is not an array|
An array, I was taught, is a sequential series of memory locations in which values of some type are stored. In an array, each of the memory locations is the same size (number of bytes). And so, as I was taught, arrays can be used very efficiently using pointer arithmetic, BUT they need to:
a) Be defined ...
Examples from our training material
|abits.c|| extern - a global variable|
|abits.h|| header file for global variable demo|
|afp.c|| Pointers and Arrays - Interaction|
|amain.c|| Use of constants and globals|
|arr1.c|| Arrays - triangle numbers|
|arrbad.c|| Arrays - triangle numbers WITH ERROR|
|eleven.c|| Array - declaration, filling with data, reusing |
|lp.c|| declaring an array and defining its length|
|makefile|| makefile for module C205|
|morearr.c|| Arrays - days and months|
|pa2.c|| Passing an array to a function - (2)|
|pa3.c|| Allocating heap memory and passing to a function|
|paif.c|| Passing an array to a function - (1)|
|par.c|| pointers v arrays |
|rainfall.txt|| Sample rainfall data (1) - always 31 days of data|
|series.c|| read array, print in reverse, min and max|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Declaring and initialising an array
Techniques for iterating through an array
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.