

Here are some of the best places to get started. Fortunately, there are lots of different resources available for learning C. Now that you’ve created your first C program, you’ll be keen to get on and learn the C language. How to learn C in Mac OS X: The best C resources and training programs You write a C program in a text editor, and then compile it using make, and then run the compiled program to see the result.Įnter rm hello.c hello to get rid of both files from your Home directory. This process is how you build and make programs in C, at least when you’re starting.

You will see “Hello, World!” at the command line. When it compiles, there will be a second file called just “hello” in the home folder.If it displays any errors, then go back and check your code. Terminal will display “cc hello.c -o hello”.Note that you don’t include the “.c” extension. Return to Terminal and enter cd ~ to make sure you’re working in the Home directory.With the “hello.c” file saved in your Home folder, it’s time to compile it.Either press the Space bar four times or press the Tab key. What’s most important is not to mix and match styles. My stance is always to use spaces unless I’m working on somebody else’s code that uses tabs. You can also use a single Tab space, and there are plenty of vibrant arguments as to which is better. Note that we use four single spaces (” “) to indent the “printf” and “return” lines. Read next: How to set up and use a Raspberry Pi 3 with a Mac More modern languages, like Python, take care of memory for you which is better for day-to-day use, but not as good educationally. This complexity is why C is used in courses such as Harvard’s CS50: Introduction to Computer Science. However, you have to learn how to allocate memory, free up memory to prevent leaks and use memory addresses and pointers (memory blocks that point to other memory blocks). All of this memory management will most likely drive you to tears at some point, but it’s superb for understanding what a programming language is doing.

The C syntax is similar to many modern programming languages. Learning C enables you to understand what’s going inside a computer in general.Ĭ is also a curious creature, in that it’s a high-level language (these are the easy ones to understand), but with low-level elements (so-called because they are “close to the metal”). The C programming language has influenced many other languages.
