Linux + C – Formatting

At this point, we've written and compiled a few C programs, and I'm sure you're already noticing the patterns. Still, it sometimes helps to have these patterns clearly defined. One Line When we talk about a line of code, we don't necessarily mean one physical line on the page. A line of code is one logical

Linux + C – Arrays

Let's be honest, folks. We don't expect to work with a few clearly defined variables forever. Sometimes we need to handle a lot of things at once, or at least a group of related things. The simplest method for lumping a group of things together is the basic data array. Arrays An array is a set of

Homework Ideas

If you're interested, here are a few assignments you can do this weekend, using just what we've talked about: Make a Fahrenheit to Celsius converter (float or int) Make a program that loops forever (you can kill it in Linux with CTRL-C) Make nested if-else chains Put an if-else chain inside of an if-else chain All of this is

Linux + C – Characters and Strings

It's time to delve into one of the enormously useful topics of programming: working with text. Characters and Strings In the past few programs, we've used the printf() function quite a bit. This magical little function generates strings and prints them to the terminal. But what exactly is a string? First, we have to understand what a

Linux + C – Doing the Math II

We've looked at the basics of performing basic math in C, but there are a few more things we should discuss before we write any code. Data Types We know that there are many different kinds of numbers. For example, we have signed numbers (which can be positive or negative) and unsigned numbers (which are assumed

Linux + C – Doing the Math I

If we're being honest, we don't start programming because we want to print out clever one-liners to a terminal. We want to calculate something complicated or massive, and we want to do it quickly. Variables, functions, and symbols We all know what a number is, right? We may behind many countries in mathematics and science, but

Linux + C – Looping

Almost every useful program requires loops and tests, which determine how the program will proceed. Without this feature, a program might as well be a text file, which generates its contents on every execute. There are three basic loops which we generally recognize. The for loop sets an initial condition when we enter the loop, then

Linux and C – “Hello, world!”

Since the release of K&R, every programmer has become familiar with the Hello, world! program. I find that learning to build this program from start to finish is an excellent introduction to the tools available in Linux. Setup First, we want to create a directory for our programs. I recommend ~/Documents/Programming, because this is a simple

Programming Environments – C in Windows

We can always install IDEs for Windows programming. I spent years working with Code::Blocks, an open-source C-flavor IDE available for Windows, Mac, and Linux. It certainly gets the job done, but like many programmers I grew tired of all the features getting in my way. I still recommend installing it if you intend to write