‘C’ is one of the greatest of programming languages that has spawned a breed of new languages. ‘C’ is not used prolifically any more and it has become a relic of the past. But it is very essential for a aspiring computer novice or for that matter an expert to spend some time understanding this great programming language. ‘C’ is quite close to the machine hardware, just next to Assembly Language. Compared to today’s languages, ‘C’ is indeed a low level language. However it is portable to a lot of extent. ‘C’ blends a unique combination of power and simplicity.
‘C’ has just three datatypes:
- float or double
char means that any variable of this datatype will occupy 1 char (character, loosely translated) which can vary from machine to machine. If say for example on an intel machine, this may be a byte. Since a byte has 8 bits, it means with char we can represent 256 combinations. If you take 1 bit for sign, this further means that we can represent numbers from –128 to +127. (256 combination) In a similar way, we have int and float or double representing say 2 and 4 or 8 bytes. If we consider this equation then the following is true:
int – 2 bytes = 65536 combinations
float = 4 bytes = 4 GB combinations
double = 8 bytes = 18,446 Exa Bytes combinations
There is no string in ‘C’. A string is represented by a series of char’s. Thus the string ‘Hello’ can be represented as below:
char string = “Hello”
where string represents ‘H’, string represents ‘e’ and so on.
The end of the string is represented by ‘’.
One of the most quirkiest things in ‘C’ is pointers. Actually the above reference for a string is wrong.
Here’s the correct representation.
char *string = “Hello” ;
*string means string is a pointer to a char starting with the char ‘H’.
Pointers are often confused with the difficulty in envisaging them, but they are quite straight forward.
There are many other features of ‘C’ which are worthy of your attention. I’ll try to cover them later.