Wednesday, October 21, 2009

RAGGED ARRARY

The two-dimensional array character type arrays occupy a fixed amount of memory space for each row that is rarely needed .Therefore , instead of making each row fixed number of characters . We can make it a pointer to a string of varying length.
The character Arrays with the rows of varying length are called "RAGGED ARRAY " and are better handled by pointer . For example :
char *cname[3] = {"india", "nepal" ,"bhutan"}; // is the declaration and intialisation of Ragged Array.

Saturday, October 17, 2009

FILE

COMMAND LINE ARGUMENT :- Command line argument is parameter supplied to a program when the program is invoked . This parameter may represent a File name the program should process . In fact main() can take two argument (from the operating system) called ARGC and ARGV .

The variable argc is an argument counter that counts the number of Argument on the commands line .Whereas argv is an argument vector and represent an array of character pointers that points to the command line argument .The size of this array will be equal to the value of argc .

POINTER

BASE ADDRESS AND CONSTANT POINTER :- When an array (any data type ) is declared , the compiler allocate a base address and sufficient amount of storage to contain all the element of the array in contiguous location .The BASE ADDRESS is the location of the first element( index 0) of the array .The compiler also defines the array name as a CONSTANT POINTER to the first element .Example int num = {12 , 5 , 107 , 55 , 291 } -- here an int type array num is declared and "num" is the constant pointer that denotes the base address of &num[0].

Friday, October 16, 2009

SCALE FACTOR

When we increment a pointer , its value is increased by the length of the data type that it points to .this length is called SCALE FACTOR .[i,e.ptr = ptr + 1 or ptr++].The no of bytes used to stored various data types can be found by making use of "SIZE OF" operator . For example , if X is a variable , the size of (X) returns the number of bytes needed for the variable.

SOME C DEFINITION

1.POINTER VALUE : It is the variable address the pointer contains and the VALUE THE POINTER to is the content of that variable whose address stored in the pointer .The "&" operator can be remembered as ADDRESS OF and the indirection operator "*" can be remembered as VALUE AT ADDRESS .We use "%u" format for printing Address values as Memory address are Unsigned Integers.