Please enable JavaScript.
Coggle requires JavaScript to display documents.
Lect 5 - Coggle Diagram
Lect 5
Variable declaration: ( =reserve space in mem,)
-
Mem address of var.: is that of the first byte of var
Pointer: spec dat. type to store mem, address of var.
Pointer:
-
var, name directly references a val.
-
-
-
Assigning Val, to a pointer
Acessing poionted var.
Asterisk operator
int i=5; int ip;
ip=&i;
printf("\n%d", ip);
printf("\n%p",ip );
-
Equality of pointer int i=5,j=3; int ip1,ip2; ip1=&i; ip2=&j;
ip2=ip1; // ip2 point to where ip1 is pointing//
printf("%d %d",ip1,ip2); // Output: 5 5
int i=5,j=3;
int ip1,ip2; ip1=&i,ip2=&j;
ip2=ip1; //Overwrite val of ip1 by ip2 //
printf("%d %d", ip1,ip2);
//Output:5 3//
Val of a pointer is the mem. address of pointer, obtained using & operator
int i=5,j;
int *ip;
ip=&i;
-
= "deferencing Operator" operator assign mem, address to ip;prvides contents in the memory location specified by a pointer
Memory treatment
Units of mem.
Bit: smallest, represent 2 val
Byte:Goup of 8 bits, represent 2^8=256 val.
Mem of Computer: Byte based, Byte is the smallest unit
Mem organiztionn
-
main memory
-
words: gr of 8 bits(1 byte), 16 bits(2 bytes), 32 bits(4 buytes), 64 bits(8 bytes)
collection of storage location, address, where prog stored
-
comp store umbers as bit pattern->address represented as bit pattern
Address starts from 0 to last addressable word in address space
Adress 64 kB( 2^6 )of mem., use 16 bits of addressing