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.


Sunday, September 20, 2009

FILE IN C

01.WHAT IS FILE IN C?
Ans: A file is a place on the disk where a group of related data stored in. the keyword "FILE" is a data type that is defined in the I/O libary . The FILE type pointer contains all the infomation about the FILE is subsequently used as a communication link between the system and the program.

OPENING THE FILE: when working witha stream-orinted data file , the first step establish a "buffer area" ,where information is temporarily stored while being transferred between the computer's memory and data file .This buffer area allows information to be read from or written to the data file more rapidly than would otherwise be possible .
The buffer area is establish by writing
FILE *fp1 ;

Tuesday, September 8, 2009

CONSTRUCTOR (JAVA)

01.WHAT IS COSTRUCTOR IN JAVA?
ans. in java constructor initialize an object.In consturctor class name and constrructor name must be same .It has no return type even void .

CONSTRUCTOR are two type in java.i)default , ii)parameterized.

EXAMPLE:
class A{

A(){ // DEFAULT CONSTRUCTOR......
}

A(1,2,3){ //PARAMETERIZED CONSTRUCTOR...
}
}

N.B:IN JAVA COPY CONSTRUCTOR NOT SUPPORTED i,e.IN JAVA COPY CONSTRUCTOR NOTHING BUT A GENERAL CONSTRUCTOR.......

Wednesday, September 2, 2009

CALL BY REFENCE.

swapping the two no.

void main()
{
void myudf(int * , int *); //function declaration ....ansi or modern style.....
int nx , ny ;
int *px , *py ;
px = &nx ;
py = &ny ;

printf("ENTER TWO NO.S ") ;
scanf("%d %d" , px ,py);

myudf(px , py); // funtion calling.....................

printf("BACK TO MAIN: THE FISRT NO IS[%d] AT ADDR [u] SECOND IS :[%d] AT ADDR [%u] " , *px , px , *py , py );

getch();
}
//............END OF MAIN............................

void myudf( int *pnx , int *pny)
{
int z ;

z = *pnx ;
*pnx = *pny ;
*pny = z ;

printf("AT UDF : NOW THE FIRST NO. IS:[%d]AT ADDR [%u] THE SECOND NO.[%d] AT ADDR [%u] " ,*pnx , pnx , *pny , pny );

getch();
}