Archive for the ‘C programming Tips’ Category

enum in C programming

Monday, April 29th, 2013

enum is a data type in C language which allows to declare constants like macros. Preprocessor macros are used widely to define constants.

(more…)

Handling Heap Allocations

Friday, February 1st, 2013

Programs at runtime, use two types of memory to store data. The first is called stack, allocations and deallocations on are managed implicitly by the compiler and for this reason it is sometimes called automatic memory.

(more…)

Top 101 mistakes done by novice C programmers

Monday, January 21st, 2013

A must read series  of articles on ” Top 101 mistakes done by novice programmers C”

(more…)

Bitwise operations in C

Thursday, January 17th, 2013

Operations on bits at individual levels can be carried out using Bitwise operations in C programming language. This document  introduces to bitwise operators in C . Bitwise operations are often applied in diverse programming scenarios to achieve different objectives . Following is a partial list of few scenarios.

(more…)

C standards

Sunday, January 13th, 2013

C is a procedural language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language, such as in system programming.

Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.

Origin

The initial development of C occurred at AT&T Bell Labs between 1969 and 1973 according to Ritchie, the most creative period occurred in 1972. It was named “C” because its features were derived from an earlier language called “B”, which according to Ken Thompson was a stripped-down version of the BCPL programming language.

The origin of C is closely tied to the development of the Unix operating system, originally implemented in assembly language on a PDP-7 by Ritchie and Thompson, incorporating several ideas from colleagues. Eventually they decided to port the operating system to a PDP-11. B’s inability to take advantage of some of the PDP-11’s features, notably byte addressability, led to the development of an early version of C.

(more…)

Source navigation using ctags

Thursday, January 10th, 2013

C projects have thousands of lines of code divided into hundreds in some cases thousands of files. In order to access various function definitions within the source code repository effectively using a VIM editor there is a great need of source browsing tools.  ctags is one of the popular source browser  tool. Though it has been around for many years, even many seasoned Linux developers are unaware of its abilities and usefulness.

(more…)

Macros in C

Wednesday, January 9th, 2013

While programming, we depend upon a condition where we want to use a value or a small piece of code many times in a code. Also there is a possibility that the in future, the piece of code or value would change. Then changing the value all over the code does not make any sense. There has to be a way out through which one can make the change at one place and it would get reflected at all the places. This is where the concept of a macro fits in. This article explores basics on Macros in C.

(more…)

Inline functions vs. Function-like Macros

Tuesday, December 4th, 2012

Most C programmers are confused about when to use inline functions and function-like macros.

(more…)

Static keyword in C

Friday, November 30th, 2012

Introduction

static keyword has multiple uses in C code and slightly different behavior in each case. For a beginner it might seem like a total anarchy. So, let’s get to the point and understand implications of using static in our code.

(more…)

Extern keyword C

Wednesday, November 21st, 2012

Most newbies are often not clear about the of why and when extern keyword should be used. In this article I will attempt to give your more clarity on extern keyword and its importance.

(more…)