Exercises, examples and other material relating to training module C210. This topic is presented on public courses
Learning to Program in C,
Learning to program in C and C++,
Programming in C,
C and C++ Programming,
Learning to program in C and C++,
C and C++ Programming
Background
How to open, read, write, and close files in C; how to
check whether or not a file exists, and how to find out the
names of all the files (and subdirectories too) in a directory.
Articles and tips on this subject | updated |
4340 | Simple C structs - building up to full, dynamic example During the final day of our "Learning to program in C" course - today - we built up an example that introduced structs, then added dynamic memory allocation so that we ended up with a flexible program capable of taking an unlimited amount of data. The build up examples also show (in the last program) ... | 2014-12-03 |
4339 | Command line and file handling in C A simple new example of command line and file handling from yesterday's C course - [here] - reading all the files named on the command line, and reporting on the length of each of them.
It's so easy to go straight from "Hello World" tp a very complex example, and loose all the delegates / readers along ... | 2014-12-03 (short) |
3386 | Adding the pieces together to make a complete language - C Once we've covered the fundamentals of programming on a C course, we move on to cover pointers, arrays, structures, strings, input/output, and dynamic memory allocation. We teach and illustrate each of them, and we have our delegates write practical exercises to make sure that they have a grasp of ... | 2011-08-11 |
3122 | 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 ... | 2011-01-08 |
2572 | The what and why of C pointers If you put a "*" in front of a variable name as you declare the variable in C, that variable holds the ADDRESS of a value of the type give, rather than the value itself. Thus:
int bill; /* holds an integer */
int *ben; /* holds an ADDRESS. At that address you'll find an integer ... | 2010-01-13 |
2571 | Reading and writing files in C In C you can use either open or fopen to open a file. open is what you would use for binary files, and you have plenty of low level controls; use fopen for text files.
When you fopen a file, you'll get back a pointer to a structure of type FILE which you then pass into function such as fgets and fprintf.
Each ... | 2010-01-13 |
2002 | 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 ... | 2009-01-20 |
Examples from our training material
cmelk.c | Text file read and write |
deardir.c | Parsing a directory |
ffiles.c | fopen to access files at a higher level |
filesinc.c | low level file handling with open |
lunches.c | Reading a file and tokenising into a structure |
sf.c | Reading all the files named on the command line |
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
[here].
Topics covered in this module
stdio.h and other headers.
Files and other streams.
Opening and closing.
Reading and writing.
Checking files and directories.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.