This is a post on what is the actual C programming language.Its not gonna be a some sort of a tutorial or a how to just some clarifications for many friends of mine who predominantly use Turbo C to write program and “LET US C” to read.The C programming language was developed by K&R and it was a path breaking development.There were independent libraries and implementation by different compilers so it was decided to standardise C as POSIX was used to standardise UNIX.The standards released in the year 1989 are refered to us C89 standard,the latest ISO standard release is refered to us C99 the official ISO standard C.
As Indian institutions specify “Let us C” which never covers these issues students are kept ignorant of it.I actually heard of C99 from Joe and got the book The C complete reference book by hibert shild which covers the C99 standards in great detail.Common mis conceptions of a Turbo C programmer:
*There s nothing called the Conio,alloc.h(for malloc),dos.h,graphics.h in the ISO standard C language.
*Standard library methods are defined in stdlib.h which programmers should use.
*”Implicit int rule” never holds yet but i see quite a lot of aptitude questions based on this “ignorance is bliss” that is if a function does not return a value it is implicitly returns an Integer this is not part of standard.
* There are many new and amzing features added to C99 this may raise some eyebrows:
->Inline functions are supported in C never say it as a difference between C and C++ to your interviewer you may land up in trouble if he knows C99 :-).
->Variables can be declared with in a block and they have no scope outside the block for example the variables used in for loop can be declared using C++ style this makes code maintainable.
for(int i=0;i<foo;i++) works in C++ :-). Simillarly you can declare variables with in If block and while loops also.
->Variable length arrays are now available in C99 that is conventionally C compiler needs you to specify the size of an array the normal methodology followed is to declare an array of huge size wasting considerable amount of memory being wasted.So you declare something like this int a to store some ten numbers.So now we have something called variable length arrays that is you can get the size at run time.
Like this : int foobar(int size)
} would work kickass right:-).So C is back with a bang.
*Why is people are unware of this is basically due to windoze addiction.Probably break your prejudice try out GNU C.GCC compiler can be used to compile a program in C99 standard as follows:
$ gcc -std=C99 -o foo foobar.c
This will compile the C program foobar.c in C99 standard.
*Another feature is we can mark a pointer as restrict its a qualifier used which will actually ensure that any access to the variable pointed through the restrict pointer can be accessed only through the particular pointer.
For eg: restrict const char *a=s;
Thus access to s can only be through pointer *a*.This highly advantageous in certain case.Take for example the strcpy(char *src,char *dest) standard library function now what if src and dest point to the same variable the operation is undefined thus in C99 –> strcpy(restrict char * src,restrict char * dest) will ensure that they are different variables.
So use GNU/Linux or any UNIX its the time to grow up and say “I am not a kid anymore”.It s high point we use a standard compiler.