Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - 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 C209
Structures and Unions
Exercises, examples and other material relating to training module C209. 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
Data doesn't come neatly packaged in a series of similar (homogenous) elements - instead, if you have a number of different attributes of a thing (or object), each of them may be of a different type (i.e. heterogenous). C's structs allow you to define your own data types as composites of other data types, with each individual member having a name and characteristics suitable to its particular data and function.
Articles and tips on this subjectupdated
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 ...
2011-08-11
 
3145Structures v Structure Pointers in C. How, which, why.
A Structure in C is a series of sequential memory locations in which you may store and access all the various attributes of a piece of composite data; you define what each of the member elements is with a typedef and then declare variables of that new type. There's a simple example [here] which defines ...
2011-01-25
 
3122When is a program complete?
"Code is never completed ... it can always be improved." ... it's one of the most difficult aspects in many projects to say "yes, that does what we want and we should go for a release now rather than continuing to develop until ... until it's so late that we've missed the boat / added too much complexity ...
2011-01-08
 
2573C Structs - what, how and why
If you want to hold a whole series of different values about something in a C program, you'll define yourself a structure (or struct.). You give a type and name to each of the elements in the structure, and then you give an overall variable name to each instance of the struct that you create. Here, ...
2010-01-13
 
1669What are Unions (C programming)
Structures are used to hold a whole lot of different pieces of data in a collection - by element name not number. Sometimes, you’ll only want to hold some elements of your structure in specific circumstances - a good example is where you have a whole lot of similar things you’re describing, ...
2008-06-10
 
1584Using Structs and Unions together effectively in C
C's Structs allow you to define a number of different variables, of different types and sizes, sequentially within a collection - you could, for example, define an animal as being: typedef struct {   char name[15];    float age;    char breed[15];   } animal; But ...
2008-03-22
 
1572C - structs and unions, C++ classes and polymorphism
C's structs allow you to define a variable type in which you can hold a variety of elements by name ... and that's very similar to how you define all the variables within a C++ class. In a C++ class, though, you also define your methods which take that language forward into the Object Oriented world. C's ...
2008-03-18
 
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 ...
2007-12-19
 
Examples from our training material
combo.c   stuctures - a first example
combo2.c   stuctures - adding pointers
combo3.c   stuctures - array of structs
dinners.c   The difference between . and -> to access a structure
lunches.c   Read file into array of structs
mytrains.c   Use of pointer to a structure
ot2.c   Defining and using a structure
ot3.c   Structure with char pointer
ot4.c   Pointer to malloc'd memory from a structure
reso.c   Struct, Structures and Structure Pointers
services.txt   Data for trains_06.c example
sixteen.c   Setting up and using structures on the heap
st1.c   Definition and first use of a structure
trains.c   An array of structures
trains_01.c   Simple demonstation of a structure
trains_02.c   Copying Strings in and out of a structure
trains_03.c   An Array of Structures
trains_04.c   Structure Pointers
trains_05.c   Dynamic allocation of memory for structs
trains_06.c   Dynamic allocation for struct and struct pointers, and populating from file
ts.c   definition and use of structure
ts2.c   Definition and use of pointer to structure
tud.c   A Union within a struct - practical use demonstration
union.c   Example of a Union in C
ztwo.c   C (towards C++), Septmeber 2018
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
Combining data into structures.
Creating your own data types.
Programming techniques for structures.
Overlapping data within unions.
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., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.info/resources/C209.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb