Training, Open Source Programming Languages

This is page http://www.wellho.net/mouth/3122_Whe ... lete-.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
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))
When 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 to make the program useful and viable". Anyone who's managed a software project may be very familiar with this sort of decision, and how hard it is to make.

A similar thing happens with examples on our web site ... "Wouldn't it be nice if this example also showed xxx" we'll say to ourselves, or "should it also check for yyyy". But, alas, the result of adding in xxx, yyyy and zzzzz while we're at it means that the example is far less followable in showing the basic fundamental elements.

Yesterday, I recalled an example that reads a web server log file in a C program and stores pertinent elements into a growing array (via realloc) of structures. (See [source]). But the code included the opening of the log file as follows:
  fh = fopen("ac_20100630","r");
Now - that's all well and good, except that the program is fixed to a specific log file, and exited with a nasty segmentation fault if the file did not exist. Discussion ensued, and we modified the code to:
  fh = fopen(*++argv,"r");
  if (! fh) {
    printf("Oh Shdear ... no file\n");
    return (1);
    }


Better? Yes. Perfect? No! it would have been a good idea to echo out the name of the file we failed to open, give an excuse the reason, such as "no such file" or "not readable", etc ... all of which would have contributed to flannel which would render the original example far too dilute in what it intended to show.

A good approach that I've often taken is what I describe as "build up examples", where I keep a whole series of versions / snapshots showing how code has developed; here's such a series from yesterday, looking at handling the command line inputs in C which provided a very good and interesting example of handling of character strings, individual characters, and the arrangement of data into somewhat more complex layouts.
Step 1, Step 2, Step 3, Step 4

There's a further "build up" example showing the first use of structs (structures) in C ... and that's here:
Step 1, Step 2, Step 3

And even building up examples like that, we sometimes produce some interesting sideshoot examples - [here] is one that looks at the thorny issue of string comparison; written during the course, although it largely duplicates [this example] from the course.

(written 2011-01-06, updated 2011-01-08)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C210 - C and C based languages - File Handling
  [2002] New C Examples - pointers, realloc, structs and more - (2009-01-20)
  [2571] Reading and writing files in C - (2010-01-12)
  [2572] The what and why of C pointers - (2010-01-13)
  [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)

C209 - C and C based languages - Structures and Unions
  [1478] Some new C programming examples - files, structs, unions etc - (2007-12-19)
  [1572] C - structs and unions, C++ classes and polymorphism - (2008-03-13)
  [1584] Using Structs and Unions together effectively in C - (2008-03-21)
  [1669] What are Unions (C programming) - (2008-06-08)
  [2573] C Structs - what, how and why - (2010-01-13)
  [3145] Structures v Structure Pointers in C. How, which, why. - (2011-01-25)

C206 - C and C based languages - Character Strings
  [1338] Handling Binary data in Tcl (with a note on C) - (2007-09-09)
  [2843] String functions in C - (2010-06-30)
  [2844] Learning about Regular Expressions in C through examples - (2010-06-30)
  [3144] Setting up arrays in C - fixed size at compile time, or dynamic - (2011-01-24)
  [3146] Strings in C - (2011-01-25)
  [3593] Chars, char arrays and strings in C. Some early cautions and pitfalls. - (2012-01-26)
  [3718] Splitting a record into individual data values in C - (2012-05-04)
  [4556] Strings in C - strncmp strncpy and friends - (2015-10-27)
  [4633] String handling in C - new examples of extracting integers from a string - (2016-01-27)


Back to
New year, new C Course
Previous and next
or
Horse's mouth home
Forward to
C++ objects - some short, single file demonstrations
Some other Articles
Car Parking in Melksham - thoughts on the proposed scheme, and wider thoughts too
The family is defunct. Long live the family.
C++ - putting the language elements together into a program
C++ objects - some short, single file demonstrations
When is a program complete?
New year, new C Course
Learning to write good programs in C and C++ - separating out repeated code
TransWilts - some things to see and do
Arrays of arrays - or 2D arrays. How to program tables.
Opportunities for Melksham - new businesses in the town
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).

© 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/3122_Whe ... lete-.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb