C for Java Programmers: Tutorial

George Ferguson

Summer 2018
(Updated Summer 2020)

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
Creative Commons License

Overview

This is not an “Intro to Programming” tutorial. It’s also not an “Intro to Computer Science” tutorial.

This tutorial is for programmers who already know how to program in Java and want to learn how to program in C. It will take you through a series of short programming challenges, each of which you should already be able to do in Java, but we will help you do them in C.

We assume that you already know how to program in Java, and that you are familiar with dynamic data structures like lists, trees, etc. These subjects are usually covered in “CS1” and “CS2” in most Computer Science programs. They are CSC171 and CSC172, respectively, at the University of Rochester.

This tutorial is designed to accompany the guide C for Java Programmers. If you are new to programming in C, we STRONGLY recommend reading the guide before you jump into coding. It describes how Java is an evolution of C, and therefore what they have in common and how they are different. Please, please, please read it before you start.

Lessons

  1. Hello World

    In this lesson, you will make sure that your C development environment is setup properly by creating a very simple first application in C.

  2. Basics

    In this lesson, you will write basic programs from an “Intro to CS” course using C. These should not be hard since C and Java are very similar.

  3. Objects

    In this lesson, you will learn how to implement representations of complex objects, as in object-oriented programming. C is most definitely not an object-oriented programming language, but with a few basic coding patterns and some discipline, you can have many of the benefits of OOP in your C programs.

  4. Binary Search Tree

    In this lesson, you will create a binary search tree in C. This is a tree data structure with the property that the left subtree of any node contains only values less than the parent and the right subtree contains only values greater than the parent. You should be familiar with implementing trees using Java.

  5. Reusable Code

    In this lesson, you will learn how to write code that you can reuse and share between programs using header files and separate compilation.

  6. Linked List

    In this lesson, you will learn how to implement a reusable, “generic” linked list structure that can store any type of object. You should be able to adapt this technique to other data structures such as graphs or trees.