Take this
course

Software Development / Web Design

C Programming For Beginners

Learn C in ten easy steps on Windows, Mac OS X or Linux

Description

The fastest, easiest way to learn to program C on a Mac or Windows. This course will teach you to program the C language from the ground up. You will learn everything from the very fundamentals of programming right through to the complexities of pointers, addresses and File IO. Maybe you've tried to master C before but failed. Or maybe you are new to C or new to programming. If so, this is the course for you!


C is one of the most important of all programming languages. It is used to program desktop applications, compilers, tools and utilities and even hardware devices. The C language is fast and efficient – but it can be hard to learn. Unless you use this course. This course begins with a gentle introduction to C but quickly moves on to explain some of its most confusing features: everything from C's 'scoping' rules to the curious connection between arrays and memory addresses. By the end of the course you will have a deep understanding both of the C language itself and also of the underlying 'architecture' of your computer. 

Full details

Curriculum

  • Getting Ready
    Welcome to the Course
    C is an important cross-platform programming language. In this video, I provide a quick introduction to the language and how to learn it using this course.
    4:09
    C Editors and IDEs
    In order to write C programs you will need a suitable editor or IDE (Integrated Development Environment). Here are a few suggestions…
    2:00
    Install CodeLite
    In this course I will generally use the free CodeLite C editor which is available for OS X, Windows and Linux. This video shows how to get CodeLite installed on your computer.
    2:13
    Install C compiler on a Mac
    If you are using a Mac you may need to download some additional tools so an editor such as CodeLite is able to find a compiler to build and run your programs.
    3:19
    Introduction to CodeLite
    Let’s take a quick look at the features of the CodeLite editor – from syntax colouring to keyboard shortcuts. CodeLite makes light work of creating C projects on Windows and OS X.
    5:19
    Programming C with NetBeans
    Maybe you are already use the NetBeans IDE for Java programming. Or maybe you'd just like to use NetBeans as your C environment. Here I explain how to get up and running.
    2:13
    Importing Projects Into NetBeans
    There are various ways of importing source code into NetBeans. Here I show a simple way of creating a NetBeans C project using the files from one of my sample projects.
    5:56
    Compiling C Programs at the System Prompt
    You don't need to use an IDE at all. If you are having problems installing an IDE or if you'd prefer to use a simple text editor, you can do so – and compile your programs in a System or Terminal window.
    9:40
    Using Visual Studio
    If you are using Windows, Microsoft’s Visual Studio (even the free edition) may be used to create C projects. Here I explain how to do that.
    6:32
    The Little Book Of C
    C Source Code
    C Programming FAQ
  • C Programming Basics
    A First Program - Hello world
    Here I take a look at a simple program that just displays “Hello world” and discover that even a few lines of C code illustrate a number of important features of the C language.
    6:07
    Arguments and Return Values
    Some “Hello world” programs are more complex than others. Here I look at a program that takes some data as ‘arguments’ and returns a value.
    4:11
    Passing Commandline Arguments to Your Program
    Here I explain how to pass arguments from the commandline (or Terminal) to your program.
    5:14
    How to Open a Command Prompt on Windows or OS X
    If you don’t know how to open a command window on Windows or the Terminal on OS X and use it to run your programs, this lesson explains all.
    4:36
    Printf
    The printf() function lets you display the output from your program. It’s a very useful function but must be used with care – as I explain here.
    5:18
    Comments
    You can document your code with comments that are ignored by the compiler. Here I explain two types of comments.
    1:45
  • Variables, Constants and Types
    Variables and Types
    Variables are identifiers whose values may vary during the running of your program. This video explains the basics of variables and their types in C.
    3:48
    Integers and Floating Point Numbers
    You may do calculations with both full numbers – integers – and fractional numbers – floating points. But be careful: the end results may not be what you expect!
    4:33
    Constants
    If you want to create identifiers to store values that are not expected to change during the execution of a program, you can #define them.
    3:43
    More About Constants
    Identifiers that are created using #define are often used as ‘constants’ – but, in fact, there is an alternative – using the keyword ‘const’. Here I explain the difference.
    4:45
    Naming Conventions
    What should you call your variables and constants? Here I consider some of the naming conventions adopted by man C programmers.
    5:30
  • Operators, Tests and User Input
    Operators - Equality and Assignment
    There are two ‘equals’ operators in C – one uses a single equals sign to assign a value to a variable. Another uses two equals signs to test for equality. Here I explain the difference.
    2:48
    Operators - Tests and Comparisons
    You will frequently need to make comparisons between one value and some other value. C has a number of ‘relational operators’ to help you do this.
    3:32
    Compound Assignment Operators
    Some assignment operators in C perform a calculation prior to assigning the result to a variable. These are called ‘compound assignment operators’.
    3:36
    Increment and Decrement Operators
    You can use ++ and – to add and subtract 1 from a variable. But be careful – you can put these operators either before or after a variable and the position matters!
    3:52
    If and Else Tests
    There are times when you need to take different actions according to some test condition. Here I explain how to use if..else tests.
    6:33
    Problems with gets() and fgets()
    It may seem easy to get input with gets() but this may cause problems. The fgets() function is a safer alternative – but that too may cause its own problems, as I explain here.
    7:47
    Input, Buffers and Flushing
    Sometimes you may have more data lurking in the dark corners of your computer than you are expecting. Here I explain some of the mysteries of buffers and why they need to be flushed.
    9:33
    My Own Line-reading Function
    Here I look at two possible ways of writing a function that safely reads in characters entered at the command prompt and also flushes any unneeded characters from the buffer.
    8:42
    Logical Operators
    If you need to chain together conditions when making tests, you need to use C’s ‘logical operators’.
    5:01
  • Functions, Arguments and Switch
    Functions
    We’ve used functions from the very start of this course. In this lesson I explain more about what functions are and how they really work.
    9:27
    Arguments
    You can pass data to functions are arguments that are assigned to ‘named parameters’. Here I explain the nitty-gritty details of arguments .
    6:20
    Switch Statements
    There may be times when you need to take many different possible actions depending on the value of some variable. The switch statement can help out.
    6:56
    Switch Statements in More Detail
    In this lesson I look at more examples of switch statements, including some options that are only available with some C compilers.
    5:17
  • Arrays, Loops and Break
    Arrays
    Arrays are sequential collections. You can use arrays to store lists of chars, ints and other types of data. Here I explain the fundamentals.
    3:27
    Initializing Arrays
    You can add elements to an array at the same time the array is declared. Here I show how to do this and I also explain how the results of calculations may change according to the ‘precedence’ of operators.
    6:37
    'While' Loops
    Sometimes you might want to run some code not for a predetermined number of times but for just as long as some condition remains true. You can use a ‘while’ loop to do this.
    4:27
    'Do while' Loops
    In some circumstances the code in a ‘while’ may never be run. If you want to ensure that your code is always run at least once, use a ‘do..while’ loop.
    2:54
    Break
    Sometimes it is useful to break out of a loop even if the loop’s test condition is not false. Here I explain how to use break in a ‘while’ or ‘for’ loop.
    5:20
    Break and Continue
    Sometimes you may want to break from a loop once but then continue running the loop afterwards. Here I explain the difference between ‘break’ and ‘continue’.
    5:19
    Multidimensional Arrays
    Arrays can have multiple dimensions to let you start arrays inside arrays. Here I explain how you can think of a two-dimensional array as being a bit like a spreadsheet with intersecting rows and columns.
    7:10
  • Strings, Chars and Pointers
    Strings, Pointers and Addresses
    In order to understand strings in C you need to understand how computer memory can be represented by ‘addresses’ and how pointer variables can refer to those addresses.
    3:51
    Null-terminated Strings
    Many programming languages have a dedicated string data-type. Here we revise the essential features of C strings and explain the significance of its lack of a string type.
    4:12
    Char Arrays and Pointers
    At first sight there may seem to be no difference between an array of chars such as char str[] and a char-pointer such as char *str. In fact the difference is profound and important.
    7:50
    Arrays, Pointers and Assignment
    Here I look at some more examples of using arrays and pointers and consider why you can assign to a pointer variable but not to an array name.
    6:07
    Strings and Functions, Stack and Heap
    How do you return strings from functions? Let's find out. We also look at the importance of understanding the ‘stack and ‘heap’ in your computer’s memory.
    6:59
    String Functions
    C compilers come with ready-to-use string functions. Here I look at some of the traditional functions as well as some more modern alternatives.
    9:40
    Char Functions
    There are also functions that let you analyse individual characters in order to determine to which category each char belongs.
    3:28
    Chars and Strings
    What is the difference between ‘x’ and “x”? They may look almost identical but, in fact, they are completely different – as this lesson explains.
    2:20
  • Structs, Enums, Header Files and Scope
    Structs
    Let’s imagine that you want to create a catalogue of your CD collection in which each record contains a name, the artist name, the number of tacks and a user rating. Here I explain how structs can help.
    5:45
    Typedef
    C lets you define your own named types. This makes it possible to create type names for everything from an int to a string to a custom record or struct.
    3:11
    Enums
    Enums let you created groups of named constants that can help to document your code. Here I explain their value – and their limitations.
    7:47
    Header Files
    What is the purpose of the ‘.h’ header files that most C programs include? Here I explain why header files are useful and how they are used during the compilation of your programs.
    8:13
    A Custom Header File
    Here I look at an example of a header file that provides access to a set of functions and constants that I have written.
    2:27
    Scope
    ‘Scope’ defines the visibility of functions and variables to your code. Here I explain local and global scope and look at the scoping of two variables with the same name.
    4:16
    Scope and External Files
    What is the scope of functions declared in external files – that is, functions that are in different files but the same project?
    2:45
    Static Functions and Variables
    Sometimes you may want your functions to be ‘private’ – hidden from code in other files. Here I explain how static functions can do this, and I also explain static variables.
    6:04
    Compiling from the Commandline
    To understand better how the compiler and linker work and how the compiler may rely on information from header files, try compiling your projects at the system prompt.
    7:00
  • File-Handling
    Opening and Closing Files
    In this step we look at file operations. In this video I explain how to open and close disk files in order to save and load data to and from them.
    3:12
    File Modes
    When you open a file you can use a short string to indicate the file ‘mode’. A file mode may make a file available for reading, writing or appending in text or binary format.
    2:45
    Reading and Writing a Text File
    Here I go through the code in a sample project to show how text can be saved to and loaded from a file, how the file contents can be erased and how the file itself can be deleted.
    5:06
    Count Lines in Text File
    Once you’ve opened a text file you may want to do something with the text it contains. In this video I show how to count the number of lines in a file.
    4:18
    Search in a Text File
    Now you know how to read and write text files you can write programs to process the text in a variety of ways – for example, to search for words in a file or encrypt its contents.
    4:04
  • Binary Fles and Memory Allocation
    Binary Files
    Not all files contain plain text. Some files may contain binary data – for example, if I were to save a CD database to disk, the data stored in each CD struct would have a binary representation. This video explains the basics.
    5:31
    Allocating and Freeing Memory
    Sometimes you need to allocate memory dynamically. But once you’ve finished with that memory you need to free it. This lesson gives an example of code that does this.
    5:55
    Types and Type Casts
    The C language provides a number of standard data types. Sometimes it is useful to treat one type as another type. In this lesson I explain the hows and whys of ‘type-casting’.
    7:49
    Creating a CD Database
    The final project in this course creates a database of CD structs that are saved in a binary file on disk. This video introduces you to this project.
    3:00
    Saving and Loading Records in a Binary File
    Here I explain how to save a collection of records (structs) into a binary data file and how to calculate the number of records stored before allocating memory when reading them in again.
    7:18
    Adding Records to a Binary File
    Here I explain how to create a new CD struct in memory and then append its data to the end of an existing binary file storing CD records.
    4:55
    Modifying Records in a Binary File
    Finally I show an example of how to find a record in a binary file and modify the data it contains. You can use the sample program as a basis for your own data-saving application.
    5:40
  • Conclusion
    And Finally...
    We’ve covered a lot of ground in the course on C programming. Now it’s time to move on…
    2:01
  • Quizzes and Answers
    C Quiz Questions
    C Quiz Answers

Similar Courses

More Courses by this Instructor