Oct 30, 2019

best way to learn programming in c

C is a classical programming language. Many of other programming languages are based on C. If you know how to handle C , you have a great understanding about system architecture and computer science. when we comparing with other High level languages , binaries written in C are so fast. Developers use C to build operating systems, application etc. Even malware authors use C  as their primary programming language. So in this document we are going to see 'how to learn c language'.

Preparing the learning environment.

First thing is first. You need a good text editor. You may use sublime, notepad++ or whatever you prefer. Also vim or nano is nice if you comfortable with them. Then you need a compiler to transform your source code into a executable binary. In Linux environments you can use GCC. For windows I would suggest you to use the Dev c++ compiler. When you learn C first write a source file with the text editor. Then use compiler , run it and check for output. If there is any error switch to your editor and fix them. Then compile and run it again. In this process you can use keyboard shortcuts. For an example you can use alt+tab for quickly switch between your windows. It's easy to do things in a Linux distribution. Because you can use a editor like nano and GCC in same terminal. So you can quickly do your work.

Understand characteristics of C.

As the first step you want to understand characteristics of the language. That means how the language identify code blocks, how it identify comments how to indicate a end of line etc. For an example C language uses parentheses to indicate a code block while Python use indentations. So best way to get some idea about basic characteristics of C language is find and read some simple codes.

Learn basics of system architecture.

To learn C language completely you need some basic knowledge of computer architecture. Understand things like how computer memory is made, How a value is stored on memory etc. How ever you don't need to worry about advanced stuff. Just get a quick and rough idea about them.

Data types, Naming rules and keywords.

C language uses some data types to store values. Learn what is an integer , what is a character string , how a character is saved in memory etc.  Also you want to understand naming rules of C. You can't give any name to a variable, function etc. There are some set of rules to follow. Before we go further just get a quick idea about them.

Learn about pointers.

A pointer is just a variable that holds a memory address. This concept is used in many places in C. So it is valuable to understand it first before learn about strings, functions etc. After you learn about pointers you can easily understand other things in C. This concept is difficult  to many of beginners . The reason is lack of knowledge in computer architecture. That's why I told you to learn some basics of system architecture first. If you understand how computer memory is organized, a pointer is nothing to you.

Understand functions.

In C language the concept of function is a main part. A function is a set of instruction. Normally we supply we data to a function and they return something after doing some work on those supplied data. You may see that every C program has a function called main. When you learn functions understand how we pass a string into a function. Think how we can use functions with pointers.

Inputs and Outputs.

Now you can learn to use inputs and outputs. For that you want to understand the concept of streams. After you get some basic idea about streams you can learn input and output methods. In C there are various functions to get inputs and put some strings or characters to the screen. As you know about functions and pointers you can easily learn about these things. Also learn how you can use format strings. When you use them try to think how a string is passed as a format string using pointers.

Learn to control the flow of program.

There are some methods to control the way of your program. You want to learn about if conditions, switches for loops, while loops etc. Try to combine functions with if statements . Use return values as conditions. Do experiments and learn new things.

Libraries and header files.

The real power of C language comes with libraries. In C those libraries are called as header files. These libraries hold some ready made functions to do various things. For an example studio.h file contains prototypes of functions related to inputs and outputs. Just read about essential libraries. Also open a header file with your editor and take a look at them. Try to understand how they functioning.

Learn from errors and fix them.

It is said that when programming you use 10% of the time to write your code and rest of time you spent to check why it's not working. As my experience it's totally correct. Not only newbies like us. Most experienced software engineers also get hundred of errors in codes. So we have to know how we can quickly identify an error and fix it.

Security, Error handling and exceptions.

In C language compiler is not responsible about input validations, buffer size checking etc. So you want to think about security when write programs. In our exploit writing tutorials I have explained you many vulnerabilities in C. Also you want to write stable software. For that we can try to reduce run time errors . So learn about error handling and excepts.

Memory management

C language provide a great interface to manipulate the memory. Learn how you can print memory addresses, how to use heap using malloc() , how to free memory etc.

So hear I listed some essential steps to learn C programming. You can follow them to start learning. After you learn those concepts start to write some codes. Also read and understand programs written by other people. Then you can build a great knowledge of C. I have listed some great resources bellow to learn C.

1) C for dummies. [book]
A classical book that explain many concepts in C. Actually some concepts like pointers, structures etc are not covered in this book. However I suggest you to begin with this one. Because it's beginner friendly.

2) Sams teaches C yourself in 21 days. [book]
This one is planned to learn C quickly. Concepts like multi dimensional arrays, pointers, structures are deeply explained.

3) C programming. [Android app]
An android app coded to learn C easily. (Search for Learn C by little drop)

4) Learn C the hard way [book]
This book is also written by Zed A. Shaw. (The writer of Learn python the hard way) . I hope this will be an interesting resource to learn C.

Also you can follow our C programming tutorials also. I hope you also have some great ideas and resources to learn C. We can discuss them in comment section below.Thank you for reading.

Aug 12
Outputs in C

In C there are number of ways to getting output to the screen.You can use them according to your....

May 16
Stack architecture theory tutorial

The stack is an important concept in computer science. If you are planning to learn reverse....

Mar 21
Assembly system calls

When we talk about computer programs, they do various tasks. Like printing a string to screen,....

Replying to 's comment Cancel reply