Showing posts with label C language. Show all posts
Showing posts with label C language. Show all posts
C Programming: Lession 1
Introduction with History
The Word C is the third Letter of our
Alphabets. Do you know about it? I am just joking. Actually C is Strange Word
in the Computer Field for those people who just start the programming but all
the experienced programmer as well as beginners like to program in C. Then let
us introduce it with and from where C was origin.
Many years ago there was Machine language to work with computer. These languages have lack of portability between different computer leds to the development of High level language. The first known High level language Plankalkul developed by Konard Zuse around 1948. After then Grace hoper invented a language called FORmula TRANslator (FORTRAN) in 1952-1954, widely used by Scientist and Engineer. Next LISP and then COBOL, ALGOL, APL, PL/1,BASIC and many more. But all of them have some complexity and drawback.
To solve all this complexity some scientist working for creating new language – called “C”. C was invented and first implemented by Dennis Ritchie on a DEC PDP-11 that used the UNIX operating system (1971-73). C was developed by using the basic features of some old language -ALGOL, BCPL and B – and adding new important features in all of them.
The Name C was given by Dennis Ritchie because it was came after B. BCPL developed by Martin Richards and it influenced a language called B, was developed by Ken Thompson. B leds the development of C in the 1970s.
C was developed on UNIX platform. UNIX is best known for Network Operating System. Normally UNIX was implemented in Assembly Language but after some time whole UNIX OS was again implemented in C Language.
Many version and flavor of C is being used. Around 1973, when Kernighan and Ritchie released their book “The C Programming Language ”, It become very popular and This very version of C was widely referred K & R C. Earlier C was open that means any can use this language and also can customized its functionality. It was the cause when standard of C was going to be reduce continuously. Then Standardization process of C continue after the establishment of ANSI around 1983. It took six year to Standardize the C and finally ANSI adopted it and version ANSI C was released in December 1989. C was also adopted by ISO(International Standard organization) and this version was called ANSI/ISO C.
Many years ago there was Machine language to work with computer. These languages have lack of portability between different computer leds to the development of High level language. The first known High level language Plankalkul developed by Konard Zuse around 1948. After then Grace hoper invented a language called FORmula TRANslator (FORTRAN) in 1952-1954, widely used by Scientist and Engineer. Next LISP and then COBOL, ALGOL, APL, PL/1,BASIC and many more. But all of them have some complexity and drawback.
To solve all this complexity some scientist working for creating new language – called “C”. C was invented and first implemented by Dennis Ritchie on a DEC PDP-11 that used the UNIX operating system (1971-73). C was developed by using the basic features of some old language -ALGOL, BCPL and B – and adding new important features in all of them.
The Name C was given by Dennis Ritchie because it was came after B. BCPL developed by Martin Richards and it influenced a language called B, was developed by Ken Thompson. B leds the development of C in the 1970s.
C was developed on UNIX platform. UNIX is best known for Network Operating System. Normally UNIX was implemented in Assembly Language but after some time whole UNIX OS was again implemented in C Language.
Many version and flavor of C is being used. Around 1973, when Kernighan and Ritchie released their book “The C Programming Language ”, It become very popular and This very version of C was widely referred K & R C. Earlier C was open that means any can use this language and also can customized its functionality. It was the cause when standard of C was going to be reduce continuously. Then Standardization process of C continue after the establishment of ANSI around 1983. It took six year to Standardize the C and finally ANSI adopted it and version ANSI C was released in December 1989. C was also adopted by ISO(International Standard organization) and this version was called ANSI/ISO C.
In 1995 some changes were included in C ,Version of C defined by the 1989 standard is commonly referred to as C99. After the development of C++ around 1983, to made C popular all time Standardization of C again worked and add the some new feature from C++ in 1999, This version of C was known as C99.
Latest Standardization and
modification released the version CX1 (also called C11) around 2007.
Now days, C is the first choice of any
programmer and widely adopted by Software companies because of their important
features.
Many company introduce the compiler and IDE for C language some of them are
Turbo C, Borland C, GCC and more
C compiler itself written in totally C language today
Some other language influenced by C- C++, Java, Simula,
Reference:
C the complete Reference by Herbert schildt
O' Reilly Practical C programming
wikipedia
google
Many company introduce the compiler and IDE for C language some of them are
Turbo C, Borland C, GCC and more
C compiler itself written in totally C language today
Some other language influenced by C- C++, Java, Simula,
Reference:
C the complete Reference by Herbert schildt
O' Reilly Practical C programming
wikipedia
Please give your important suggestion to improve the content
C Language : Pointer Fundamental
Pointer Fundamental
In the simplest term pointer is a nearly integer variable which stores a memmory address of a computer which may contain other variable or even another pointer.
If a variable contains address of another variable than it is said that first variable points to second. Pointer can also be represented as a refrence to another variable but there is very subtle diffrence in the two statements which is mostly dependent upon situation and enviorment.
Pointer is generally of size of integer on the machine but it may be of different type which indicates the type of variable the pointer is pointing to decides pointers properties and behaviour. Pointer of one type cannot be implicitly converted from one type to another but can be explicitly converted using type casting. In such a conversion a pointer always assumes that it is point to a object of its type but reality may differ and if used incorrectly may lead to disasters including permanent machine damage.
Also it is important to note that all operation perform on pointers are done through two operators '*' (Star) and '&' (Ampercent). '&' is a unary operator that returns a memmory address of a variable. '*' is complement of '&' and return value stored at a memmory location stored in a pointer. '*' can interpreted as statement "at address" while '&' can be interpreted as statement "address of".
Pointer Variable
Declaring a pointer variable is quite similar to declaring an normal variable all you have to do is to insert a star '*' operator before it.
General form of pointer declaration is -
type* name;
where type represent the type to which pointer thinks it is pointing to.
Pointers to machine defined as well as user-defined types can be made.
Multiple pointers of similar type can be declared in one statement but make sure you use * before every one otherwise they will become a variable of that type.
Pointer Assignment
This is a type of expression used to assign value of one pointer to another using assignment operator '=' . In this value of right hand side points to memmory address of variable stored in left hand side pointer. As a result both pointers point to same memmory location after this expression.
Pointer of similar type can be used in expression easily as shown below but for diffrent type pointers you need to type cast them as shown in next section.
In the simplest term pointer is a nearly integer variable which stores a memmory address of a computer which may contain other variable or even another pointer.
If a variable contains address of another variable than it is said that first variable points to second. Pointer can also be represented as a refrence to another variable but there is very subtle diffrence in the two statements which is mostly dependent upon situation and enviorment.
Pointer is generally of size of integer on the machine but it may be of different type which indicates the type of variable the pointer is pointing to decides pointers properties and behaviour. Pointer of one type cannot be implicitly converted from one type to another but can be explicitly converted using type casting. In such a conversion a pointer always assumes that it is point to a object of its type but reality may differ and if used incorrectly may lead to disasters including permanent machine damage.
Also it is important to note that all operation perform on pointers are done through two operators '*' (Star) and '&' (Ampercent). '&' is a unary operator that returns a memmory address of a variable. '*' is complement of '&' and return value stored at a memmory location stored in a pointer. '*' can interpreted as statement "at address" while '&' can be interpreted as statement "address of".
Pointer Variable
Declaring a pointer variable is quite similar to declaring an normal variable all you have to do is to insert a star '*' operator before it.
General form of pointer declaration is -
type* name;
where type represent the type to which pointer thinks it is pointing to.
Pointers to machine defined as well as user-defined types can be made.
Multiple pointers of similar type can be declared in one statement but make sure you use * before every one otherwise they will become a variable of that type.
Pointer Assignment
This is a type of expression used to assign value of one pointer to another using assignment operator '=' . In this value of right hand side points to memmory address of variable stored in left hand side pointer. As a result both pointers point to same memmory location after this expression.
Pointer of similar type can be used in expression easily as shown below but for diffrent type pointers you need to type cast them as shown in next section.
//
#include ‹stdio.h›
int main ()
{
char ch = a;
char* p1, *p2;
p1 = &ch;
p2 = p1; // Pointer Assignement Taking Place
printf (" *p1 = %c And *p2 = %c", *p1,*p2); // Prints 'a' twice
return 0;
}
Subscribe to:
Posts
(
Atom
)