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))
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 of new examples as I did so; the elegates gain so much more from seeing HOW I achieve the results as well as just seeing the results themselves. So I give you:

• Loops and conditionals - throwing a die until you get a six, then printing out the sum / average of all the throws [source]

• A program to head in your height and weight (in once file) and call functions in another to calculate your BMI and also to return a comment about your health. [source] and [source]

• The significance of call by value v call by name. If you call a function and pass it a COPY of the data, then no matter how much it changes the copy, it won't effect the original. But if you pass in a POINTER so that the function works ont he same data, then it CAN change it. Which is best? Both have their uses - it's a case of horses for courses. Examples - [source] and [source].

• Summing numbers typed in on the command line [source]

• How to pass an array to a function in C [source]

• Passing pointers into functions in order to allow the function to return multiple values [source]

• The difference between the . and the -> operator when used to access a member of a structure or union in C [source]

• Reading data from a file, tokenising each line into a structure and storing those structures in an array [source]

• Examples of the #define and #include pre-processor directives for setting up compile time constants and including a file of headers within multiple source files. [source] and [source]

• How do you read a file of unknown length in C and store it in memory, when you have to give you arrays a fixed size? You use the realloc function. This example shows you how to do it, setting up a block of memory which is expanded to take however much data you have in the file [source]
(written 2009-01-20)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C210 - C and C based languages - File Handling
  [2571] Reading and writing files in C - (2010-01-12)
  [2572] The what and why of C pointers - (2010-01-13)
  [3122] When is a program complete? - (2011-01-06)
  [3386] Adding the pieces together to make a complete language - C - (2011-08-11)
  [4339] Command line and file handling in C - (2014-12-03)
  [4340] Simple C structs - building up to full, dynamic example - (2014-12-03)

C205 - C and C based languages - Arrays
  [1614] When an array is not an array - (2008-04-17)
  [2840] Just pass a pointer - do not duplicate the data - (2010-06-30)
  [3118] Arrays of arrays - or 2D arrays. How to program tables. - (2011-01-02)
  [3121] New year, new C Course - (2011-01-05)
  [3144] Setting up arrays in C - fixed size at compile time, or dynamic - (2011-01-24)
  [3245] Collections in C and C++ - arrays, vectors and heap memory blocks - (2011-04-12)
  [4338] Passing arrays into functions in C - (2014-12-02)
  [4566] C - why is slow to write and debug) but fast to run? - (2015-11-01)

C203 - C and C based languages - Conditionals and Loops
  [353] Wimbledon Neck - (2005-06-20)
  [962] Breaking a loop - Ruby and other languages - (2006-12-03)
  [1191] Smart English Output - via PHP and Perl ? : operator - (2007-05-18)
  [1220] for loop - how it works (Perl, PHP, Java, C, etc) - (2007-06-06)
  [1582] Ruby, C, Java and more - getting out of loops - (2008-03-19)
  [1696] Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04)
  [2570] Function Prototypes in C - (2010-01-11)
  [3004] Increment operators for counting - Perl, PHP, C and others - (2010-10-18)
  [3200] How a for loop works Java, Perl and other languages - (2011-03-12)
  [3243] Breaking the running sequence - an introduction to conditional statements and loops - (2011-04-11)
  [3384] Loops - a comparison of goto, while and for - (2011-08-10)
  [3397] Does a for loop evaluate its end condition once, or on every iteration? - (2011-08-18)
  [4322] Learning to Program - the conditional statement (if) - (2014-11-21)
  [4323] Learning to program - Loop statements such as while - (2014-11-22)
  [4337] Learning to program sample program - past its prime, but still useful - (2014-12-02)

C050 - C and C based languages - C - General
  [2086] C Programming v Learning to Program in C. Which course? - (2009-03-17)
  [2091] C, C++ and C# ... Java and JavaScript - (2009-03-20)
  [2504] Learning to program in ... - (2009-11-15)
  [2536] All the Cs ... and Java too - (2009-12-13)
  [2669] Efficient use of dynamic memory - C and realloc - (2010-03-10)
  [2763] Our C and C++ training course are on Open Source platforms - (2010-05-13)
  [2848] C course - final course example puts it all together - (2010-07-02)
  [3053] Make - automating the commands for building and installing - (2010-11-16)
  [3129] Extra courses - C and C++ - (2011-01-12)
  [4335] Flexible public courses - residential or commuting, programming newcomer or experienced, C or C++ - (2014-11-30)
  [4341] Segmentation Fault, Segmentation Violation, Bus Error, Stack Smashing - (2014-12-04)
  [4434] Public training courses - upcoming dates - (2015-02-21)


Back to
I have not programmed before, and need to learn
Previous and next
or
Horse's mouth home
Forward to
Discount Training Courses - PHP, Perl, Python
Some other Articles
Contrast
Variables and pointers and references - C and C++
Variable Scope in C++
Discount Training Courses - PHP, Perl, Python
New C Examples - pointers, realloc, structs and more
I have not programmed before, and need to learn
2000th article - Remember the background and basics
How low can you sink?
Text on a background image
Travelling to a course - station pickups
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

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.net/mouth/2002_New ... -more.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb