Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact

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 C207
Pointers and references
Exercises, examples and other material relating to training module C207. 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

Variables in C may be declared so that they contain a reference to another variable rather than a numeric or string value. Using this facility, you can write generalised code - using a variable called "current" for example - that you can then point at a particular piece of data you want to work on. On Monday, "current" can be Lee's Chinese and on Tuesday it can the The Refa Indian Restaurant ...
Articles and tips on this subjectupdated
4560Variables, Pointers and References - C and C++
In C, you can address a memory location storing a value directly by its variable name, or you can access it via its address using a variable that contains that address - a pointer - declared using an * in the declaration, and you can then use:   * to mean contents of   & to mean ...
4128Allocating memory dynamically in a static language like C
From last weeks' C course - a complete example showing dynamic memory allocation - reading in any file of data, lines of varying length, and packing them in neat. Source code [here]. There's an issue with reading data of unknown size into a fixed declaration language like C... allocation stack memory ...
3399From fish, loaves and apples to money, plastic cards and BACS (Perl references explained)
Money's useful stuff. Before money, transactions were undertake on a barter system; if I wanted a loaf of bread I might exchange it for a fish. If I was wanting to book passage on tthe stagecoach from the George in Melksham to London, I would have to take ia bushel of apples into my local travel agent, ...
3386Adding the pieces together to make a complete language - C
Once we've covered the fundamentals of programming on a C course, we move on to cover pointers, arrays, structures, strings, input/output, and dynamic memory allocation. We teach and illustrate each of them, and we have our delegates write practical exercises to make sure that they have a grasp of ...
3238Bradshaw, Ben and Bill. And some C and C++ pointers and references too.
I have a scarse original of the January, 1960 edition of Bradshaw's guide. Bill and Ben are on my course, and they both want to take a look at it. So I take a perfect photocopy of it, and I pass that copy to Bill with the original handed, with great reverance, to Ben. Bill and Ben both spend some time ...
3242How to return 2 values from a function (C++ and C) - more uses of pointers
A further example (following previous article [here]) of where pointers are particularly useful is where you want to return nore than one resulting value from a function ... in C, that's something you couldn't really do without them. There are two ways: a) A function returns a single value ... but ...
3121New 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 ...
3004Increment operators for counting - Perl, PHP, C and others
Look at this Perl statement:   $counter = $counter + 1; "Take the value in $counter, add 1 to it, and put it back in $counter". It's a common programing requirement - indeed, so common that you can write it in a shorter form in many languages:   $counter += 1; "Add one to the value ...
2670Pointers to Pointers to Pointers - what is the point?
From today's course - a new example showing pointers to pointers to pointers. But why? C pointers are useful in many ways: • they let you pass a single value into a function that holds a whole collection of data • they let you call by 'name' so that functions can alter values (see here) • ...
2572The what and why of C pointers
If you put a "*" in front of a variable name as you declare the variable in C, that variable holds the ADDRESS of a value of the type give, rather than the value itself. Thus:   int bill; /* holds an integer */   int *ben; /* holds an ADDRESS. At that address you'll find an integer ...
2005Variables and pointers and references - C and C++
If I have a variable called "weight" that contains a float, I can use and set its value by using that name. Pointers If - in C or in C++ - I declare a variable to be a pointer then that variable may contain a memory address ... I use a * in my type declaration, and then I use & in my assignment: float ...
1497Training Season Starts again!
I'm glad that our business isn't heavily seasonal - tourist places like Longleat have a heavy summer and a barren winter, and The Christmas Shop must, surely, be heading for a quiet few months. But we are - slightly - seasonal; we have a quiet three weeks where no-one wants to learn Perl or PHP (or ...
1478Some new C programming examples - files, structs, unions etc
A series of new "C" examples have been added to the web site - a course for a small group allowed me to go somewhat away from the more normal run yesterday and write some new illustrations in front of them. Call by value v call by pointer comparison: link Using extern to share a variable between two ...
1155Pointers in C
I know when I'm giving a C Programming course that I'll come to the section on pointers and I'll have to slow right down - those extra * and & characters take a little explaining and getting used to. Here are the key points. A variable declared with a * in front of it holds a reference to (i.e. ...
Examples from our training material
arp.c   referencing array members through pointers
cli2.c   Handling command line args via pointers
dj.c   Comparing call by name and call by value
ex_c207.c   passing pointers in to a function to allow multiple returns
excuse.c   Pointers - illustrative example 1
fifth.c   Further use of pointers - returning multiple values
fourth.c   function calls - call by value and call by name
ip2.c   Passing pointers to functions
makefile   makefile for module C207
p1.c   First demonstration of a pointer
p2.c   Passing a reference to allow a variable to be change from a function
p4.c   Passing complex data via a single pointer
pdo.c   Hello pointer world
pfirst.c   use of pointer - passing to function
plot.c   Passing an array to a function
po.c   Pointers and addresses - the mechanism
psecond.c   How a pointer can give a temporary name
ptr1.c   Temperature conversions - pointers
referee.cpp   References and pointers (and direct variable use)
stock.c   Jelly beans
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 using a pointer
Pointer arithmetic
Passing pointers
The use of pointers.
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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/C207.html • PAGE BUILT: Mon Feb 8 18:55:24 2016 • BUILD SYSTEM: WomanWithCat