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))
Your program - you just provide the filling in the sandwich

You may think (and say) that you're writing a program ... but you never write a complete program these days. What you do is to provide the filling to the sandwich - the bit that changes from one application / requirement to the next, and you then make use of standard surrounding material - the bread.

On top of your code sits the standard element provided by the language that you're using that loads your program into the multi-program operating system, ensures that you don't overlap with anyone else in terms of memory, disc files, screen real estate, network ports, etc ... and which then calls your main function - i.e. calls in the filling. In C and C++ (I was running a C and C++ coursei this week, hence the selection of this language for my example) this function is actually called "main" and will be where your own code is started from.

Your own code - the filling in the sandwich - provides the bit that's specilly written for your program. The bit that does what you program it to do, and not standard stuff that someone else has already written and shipped to you in standard units that everyone uses.

And below your code sit standard functions that you call to perform tasks that are common to a whole lot of programs - routines / code in named blocks from standard libraries. That's anything from "give me memory to store more data" through functions like calloc to "output this to the current standard output destination" through functions like printf.


Even a first "Hello World" program in C illustrates this eloquently:

  main() { /* Hook from above */
      printf("Greetings, Everyone\n"); /* Calling down below */
  }


Of course, this first program is a most disappointing sandwich - it's mostly bread with only the tiniest trace of a filling. But it's the sort of code we write in the very first example of the course to show our delegates the environment in which their code sits and runs. We then expand that example a little - adding in comments to the code (very important for when you come back to look at what you wrote again later, or someone else does), a few more outputs, and perhaps calls to some of your own internal functions.

[link] - how to make a sandwich

The expanded example may be found [here] on our web site. It calls in other functions that we've written ourselves ... one of which is in the same file, and the other is in a separate file called shared.c - see [here]. The name "shared" should give you the clue that, as we expand, this is how we provide user written code that can be used in more than one application without duplicating the source code - and so without duplicating the work that has to be done in maintaining it.

Here, to complete this example, are the instructions I used on my (Unix / Mac OS X) system to compile and build the program. The same would work on Linux. On Windows, you can get gcc if you want, or you could use a different setup under which the same principle would be followed but in a different way.

munchkin:capr grahamellis$ gcc -c first.c
munchkin:capr grahamellis$ gcc -c shared.c
munchkin:capr grahamellis$ gcc -o first first.c shared.c
munchkin:capr grahamellis$ ./first
Issa MINE! Mits orf!
Have a good day!
Have a good day!
Greetings from us
Time for a coffee!!
Have a good day!
Have a good day!
munchkin:capr grahamellis$


* The first two instructions are compiling - preparing my ingredients - converting the Eglish-like source code into a sections of machine code

* The thild instructions joins all the components together into a single runnable file (and also puts them in the bread

* The fourth instruction actually runs the program ... and you'll see the results set out below it.

Every programming language has its own environment in which you enter code, prepare it to be run using standard code starting modules and library functions, and then ways of running it. And on all of our more basic courses, we'll cover this environment and how it works in one of the very early sessions. See [here] for our upcoming course schedule.

As I write, we're covering PHP next week, then Python and Tcl at the start of May on public courses. We're running private Ruby and Perl courses very soon too; the next Lua, C and C++ courses aren't for a couple of months. We've got all of the languages scheduled as public courses in the next four months ... and we're always open for bookings at least six months ahead. Why not come and learn with us? If you've never programmed before, you can find one of our courses which suits you (look for the courses named "learning to program in xxxx"). If you've programmed before, but in a different language to the one that you need to use now, book onto one of our courses described as "xxxx programming", and we'll convert you efficiently - making use of your existing knowledge of the principles of programming to get you writing good code in xxxx.
(written 2011-04-08, updated 2011-04-09)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C211 - C and C based languages - Standard Libraries and other headers
  [2575] Sharing variables between files of code in C - extern - (2010-01-14)
  [3148] OpenGL / C / C++ - an example to get you started - (2011-01-26)
  [3244] C and C++ - preprocess, compile, load, run - what each step is for - (2011-04-12)
  [4465] Sockets, time handling and keyboard interrupt handling in C - (2015-03-27)

C201 - C and C based languages - C Language Fundamentals
  [888] Turning C from source to a running program - (2006-10-06)
  [1671] Compiling C programs with gcc - an overview - (2008-06-10)
  [2005] Variables and pointers and references - C and C++ - (2009-01-23)
  [2576] What does const mean? C and C++ - (2010-01-15)
  [2842] Staring a C course with Hello World - why? - (2010-06-30)
  [3120] Learning to write good programs in C and C++ - separating out repeated code - (2011-01-04)
  [3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
  [3591] Integer types, and integer overflows, in C - (2012-01-25)
  [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
  [4324] Learning to program - variables and constants - (2014-11-22)
  [4555] Preprocessor directives in C and C++ - what they mean - (2015-10-27)
  [4566] C - why is slow to write and debug) but fast to run? - (2015-11-01)


Back to
C / C++ Course Lunch - sitting out at the West End
Previous and next
or
Horse's mouth home
Forward to
How we make our programming courses both time and cost effective
Some other Articles
Bradshaw, Ben and Bill. And some C and C++ pointers and references too.
Using functions to keep look and feel apart from calculations - simple C example
C - a first program that does something useful for you
How we make our programming courses both time and cost effective
Your program - you just provide the filling in the sandwich
C / C++ Course Lunch - sitting out at the West End
Around and about Melksham in more pictures
Footpath, Bridleway, Byway, Road used as Public Path
Whaddon - near us and yet so remote from us
Coincidence, or naturally repeating event?
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/3234_You ... dwich.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb