For 2023 - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |

Well House Consultants
You are on the site of
Well House Consultants
who provide
Open Source Training Courses
and business
hotel accommodation. You are welcome to browse and use
our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
|
C and C based languages module C205
Arrays
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
Background 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
duplicate code.
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 ... | 2015-11-01 | 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[0] 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 ... | 2014-12-02 | 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 ... | 2011-04-12 | 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:
int history[20];
and that will give you an array of 20 elements - which you can refer to as elements number 0 to 19, so:
history[4] = 1234;
to ... | 2011-01-25 | 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 ... | 2011-01-08 | 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.
What ... | 2011-01-03 | 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 ... | 2010-06-30 | 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 ... | 2009-01-20 | 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 ... | 2008-04-19 |
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 |
Background information
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
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.
Well House Consultants specialise in training courses in
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses 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.
|
|
|