Brushing up C

If you are already familiar with programming, then C language was probably one of your first encounters ☺️ . For me, it was means of bread and butter for many good years. It  paved way for learning many more software languages and tools  ☺️ .

An introduction,why C?

Lets start with, it’s super cool and smoothly takes you into amazing world of software. It’s one of the pioneers, so you can see it’s presence in many new and advanced technologies also. It is also used as an accomplice with other softwares to create efficient applications.

Desktop applications, enterprise level software use C for many of their applications. Many open source platforms like Linux, are extensively based on C.

Once you get a grasp of C, then learning other higher and more evelved technologies like C++,  Java, Scripting etc becomes easy. You also get an understanding of low level working of processors and computers if you delve in deep. So, I guess we have enough reasons to get started without wasting any more time ☺️ .

What all do we need to learn?

  • Statements
  • Data types
  • Arrays
  • Functions
  • Conditional statements
  • Memory
  • Pointers
  • Loops
  • Compiler
  • Running environment

If you need to make real world applications, then you may also know about

  • Socket Programming
  • Interrupts
  • Messaging
  • Parallel programming
  • Exception handling

Let’s start learning ☺️ .
Jump in right away!

Without talking much more, lets straight get down to some basic coding ☺️ .

1. gcc compiler

We need to ensure that gcc compiler is installed on our machine. If not, then download one and install. Linux and related flavours have  gcc preinstalledFor Mac, you may need to install xcode (using xcode-select) . Clang is another compiler for Mac.

2. Terminal window

Having worked extensively on Linux most of my life, I am very comfortable working with terminal windows and Command line instructions. You can also look for some IDE or GUI development environment if that suits you.

3. Writing code using vi

Open a new file with vi editor.

$ vi start.c

Write the following code in the file and save it. Note: familiarise with vi commands, as it will speed up writing and editing.

#include <stdio.h>

void main (void)

{

printf (“My first C program, I am loving it. \n”);
}

main is the function where the code execution starts in C . printf , as the name suggests, prints the argument string, to the output.

4. Compile the code with gcc compiler

Invoke the gcc compiler from command prompt:

$ gcc start.c

The compiler will, by default, create a file a.out.  This is the executable file. This is your first program, ready to run ☺️ .

Start your first program

$ ./a.out

$ My first C program, I am loving it.

As you can see above, what we passed to printf  is displayed on the command prompt.

Congratulations, your first C code runs !

Here, I conclude the first part of the series. ☺️

Software is mastered by doing. Reading can give you a perspective, actually working with the technology gets  the blood rushing 😀 . Please practice, and incase you face issues, feel free to send in your queries. I would love to help out .

Brushing up C part 2 is here.

Here is my blog on Python, python simplified .

Advertisements

6 thoughts on “Brushing up C

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s