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 different sources:
link and
link
Handling command line parameters through pointers:
link
Structures, and pointers to structures:
link and
link
Unions, where memory is shared between variables:
link
File handling through open and read, fopen and fgets compared:
link and
link
And some
C++ examples:
Fomatting floating point numbers in C++:
link
Using a vector (in effect an object that's an array but can be extended as required:
link
All examples have comments and sample outputs included and will open in a new window if you click on the links. All simple examples, and they're often the best!
(written 2007-12-19)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C204 - C and C based languages - Functions, Macros and programs in multiple files [3721] Naming blocks of code, structures and Object Orientation - efficient coding in manageable chunks - (2012-05-06)
[3717] Returning extra results from a function in C - (2012-05-03)
[3237] Using functions to keep look and feel apart from calculations - simple C example - (2011-04-09)
[2841] C Course exercise and sample answer - source in 2 files - (2010-06-30)
[2575] Sharing variables between files of code in C - extern - (2010-01-14)
[2570] Function Prototypes in C - (2010-01-11)
[1163] A better alternative to cutting and pasting code - (2007-04-26)
[775] Do not duplicate your code - (2006-06-23)
C207 - C and C based languages - Pointers and references [3399] From fish, loaves and apples to money, plastic cards and BACS (Perl references explained) - (2011-08-20)
[3386] Adding the pieces together to make a complete language - C - (2011-08-11)
[3242] How to return 2 values from a function (C++ and C) - more uses of pointers - (2011-04-10)
[3238] Bradshaw, Ben and Bill. And some C and C++ pointers and references too. - (2011-04-09)
[3121] New year, new C Course - (2011-01-05)
[3004] Increment operators for counting - Perl, PHP, C and others - (2010-10-18)
[2670] Pointers to Pointers to Pointers - what is the point? - (2010-03-10)
[2572] The what and why of C pointers - (2010-01-13)
[2005] Variables and pointers and references - C and C++ - (2009-01-23)
[1497] Training Season Starts again! - (2008-01-07)
[1155] Pointers in C - (2007-04-19)
C209 - C and C based languages - Structures and Unions [3145] Structures v Structure Pointers in C. How, which, why. - (2011-01-25)
[3122] When is a program complete? - (2011-01-06)
[2573] C Structs - what, how and why - (2010-01-13)
[1669] What are Unions (C programming) - (2008-06-08)
[1584] Using Structs and Unions together effectively in C - (2008-03-21)
[1572] C - structs and unions, C++ classes and polymorphism - (2008-03-13)
C235 - C and C based languages - I/O in C++ [3810] Reading files, and using factories to create vectors of objects from the data in C++ - (2012-07-21)
[3807] Reading (and writing) files in C++ - (2012-07-18)
[3390] Printing objects in C++ - (2011-08-13)
[3252] C++ - unknown array size, unknown object type. Help! - (2011-04-17)
[3124] C++ - putting the language elements together into a program - (2011-01-08)
[1675] Comparing Objects in C++ - (2008-06-13)
C238 - C and C based languages - Templates [3982] Using a vector within an object - C++ - (2013-01-19)
[3509] Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses - (2011-11-06)
[3388] Templates in C++ - defining a family pattern of methods / functions - (2011-08-12)
[3245] Collections in C and C++ - arrays, vectors and heap memory blocks - (2011-04-12)
561e
Some other Articles
A story about benchmarking PHPThe Christmas LetterNext course - 7th January 2008, Regular ExpressionsFSB leaves its members feeling like mushroomsSome new C programming examples - files, structs, unions etcDecisions - small ones, or big ones?Shopping for Christmas and looking forwardTcl/Tk - updating your display while tasks are runningUsing Tcl/Tk resource files for flexible applicationsMaking a variable dynamically visible in a Tcl/Tk GUI