Posts

Showing posts from October, 2007

Array of Pointers & Pointer to an entire array

Lets take it by an example: int *p[N]; , where N is any integer number is a declaration for an array of N pointers of type int. This means that if we declare as: int *p[5]; then, p[0], p[1]. … ,p[4] will all be pointers of type int, ie,, they point to memory locations allocated for integer data. Coming to Pointer to an entire array can be declared as say: int (*a)[N]; where N is any integer number. This means that int (*a)[5]; is the declaration for a pointer to an array of length 5 of type int. This is purely a matter of precedence. In the former case, for int *p[5]; Since [] has higher precedence that *, p is recognized as an array first and the * shows that it an array of integer pointers. For the secod case, for int(*a)[5]; the default precedence is overridden by the common paranthesis. Thus, now a is a pointer first and the [] makes it a pointer to an array.

Java vs JavaScript

First of all: Java is not JavaScript and JavaScript is not Java. Java is an Object oriented programming language created at Sun Microsystems, where as JavaScript is a scripting language and is a product of Netscape. Many of their programming structures are similar as they both use the C-style syntax. But, JavaScript has a smaller and simpler set of commands. Moving on, Java can stand on its own, ie,, a program written in Java can be executed on its own, whereas for JavaScript, the code must be embedded inside HTML code for execution on a webpage. In other words, Java can be used to create standalone applications, whereas it is impossible using JavaScript. For the execution of the java program, it is first compiled to form byte codes and these byte codes are interpreted by the Java runtime environment for execution, which makes the execution slower. As for JavaScript, there is no compilation phase. Instead, the JavaScript code is directly interpreted by the web browser for e...