enum is a data type in C language which allows to declare constants like macros. Preprocessor macros are used widely to define constants.
Archive for the ‘C programming Tips’ Category
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.
A must read series of articles on ” Top 101 mistakes done by novice programmers C”
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.
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.
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.
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.
Most C programmers are confused about when to use inline functions and function-like macros.
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.