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
C238 - C and C based languages - Templates [3245] Collections in C and C++ - arrays, vectors and heap memory blocks - (2011-04-12)
[3252] C++ - unknown array size, unknown object type. Help! - (2011-04-17)
[3388] Templates in C++ - defining a family pattern of methods / functions - (2011-08-12)
[3509] Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses - (2011-11-06)
[3810] Reading files, and using factories to create vectors of objects from the data in C++ - (2012-07-21)
[3982] Using a vector within an object - C++ - (2013-01-19)
C235 - C and C based languages - I/O in C++ [1675] Comparing Objects in C++ - (2008-06-13)
[3124] C++ - putting the language elements together into a program - (2011-01-08)
[3390] Printing objects in C++ - (2011-08-13)
[3807] Reading (and writing) files in C++ - (2012-07-18)
[4562] Left shift operator on an output stream object - C++ - (2015-10-30)
[4563] Formatting and outputting your own classes in C++ - (2015-10-30)
C209 - C and C based languages - Structures and Unions [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)
[3122] When is a program complete? - (2011-01-06)
[3145] Structures v Structure Pointers in C. How, which, why. - (2011-01-25)
[3386] Adding the pieces together to make a complete language - C - (2011-08-11)
C207 - C and C based languages - Pointers and references [1155] Pointers in C - (2007-04-19)
[1497] Training Season Starts again! - (2008-01-07)
[2005] Variables and pointers and references - C and C++ - (2009-01-23)
[2572] The what and why of C pointers - (2010-01-13)
[2670] Pointers to Pointers to Pointers - what is the point? - (2010-03-10)
[3004] Increment operators for counting - Perl, PHP, C and others - (2010-10-18)
[3121] New year, new C Course - (2011-01-05)
[3238] Bradshaw, Ben and Bill. And some C and C++ pointers and references too. - (2011-04-09)
[3242] How to return 2 values from a function (C++ and C) - more uses of pointers - (2011-04-10)
[3399] From fish, loaves and apples to money, plastic cards and BACS (Perl references explained) - (2011-08-20)
[4128] Allocating memory dynamically in a static language like C - (2013-06-30)
[4560] Variables, Pointers and References - C and C++ - (2015-10-29)
C204 - C and C based languages - Functions, Macros and programs in multiple files [775] Do not duplicate your code - (2006-06-23)
[1163] A better alternative to cutting and pasting code - (2007-04-26)
[2570] Function Prototypes in C - (2010-01-11)
[2575] Sharing variables between files of code in C - extern - (2010-01-14)
[2841] C Course exercise and sample answer - source in 2 files - (2010-06-30)
[3237] Using functions to keep look and feel apart from calculations - simple C example - (2011-04-09)
[3717] Returning extra results from a function in C - (2012-05-03)
[3721] Naming blocks of code, structures and Object Orientation - efficient coding in manageable chunks - (2012-05-06)
[4338] Passing arrays into functions in C - (2014-12-02)
[4554] Passing information into functions in C - by name, by value - (2015-10-26)
[4555] Preprocessor directives in C and C++ - what they mean - (2015-10-27)
[4557] Function prototype - what they are and why you should use them - C and C++ - (2015-10-27)
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