C Language - 01

  • Published on
    14-Aug-2015

  • View
    31

  • Download
    0

Transcript

  1. 1. 01/11/56 AdvanceComputerProgramming:. 1 Advance Computer Programming 32090207 . 1 1 1. Pointer 2. Pointer Array 3. Pointer Function 4. Dynamic Array . 1 2 Pointer . 3 3 Pointer Pointer Operator C Dynamic data structure Pointer ( ) * int *variable; * int* variable; . 1 4
  2. 2. 01/11/56 AdvanceComputerProgramming:. 2 Pointer . 1 5 Pointer Array . 6 6 Array Pointer 3 . 1 7 Pointer 1 Array 3 Column 0 1 2 a[0] Data Data Data a[1] Data Data Data a[0] Data Data Data . 1 8 int (*a)[3]; a = new int[n][3];
  3. 3. 01/11/56 AdvanceComputerProgramming:. 3 Pointer 1 Array 3 Column . 1 9 Pointer Function . 10 10 Reference . 1 11 Address Value B 1000 10 1001 *A 1002 1000 1003 **P 1004 1002 1005 1006 Reference . 1 12 *a === **p
  4. 4. 01/11/56 AdvanceComputerProgramming:. 4 Pointer Function . 1 13 Dynamic Array . 14 14 int a[5] ; . 1 15 int *b ; 0 1 2 3 4 a : b Array Dynamic Array Pointer Array . 1 16
  5. 5. 01/11/56 AdvanceComputerProgramming:. 5 Dynamic Array int *b; b = new int[n]; . 1 17 0 1 2 n b b Address Dynamic Array 2 ? int **c ; c = new int [n][m] ; . 1 18 Dynamic Array 2 int (*c)[4]; Pointer int **c; c = new int [n][4]; . 1 19 Array 2 int a[3][4]; . 1 20 0 1 2 3 0 0 1 2 3 1 4 5 6 7 2 8 9 10 11 j Column i Row
  6. 6. 01/11/56 AdvanceComputerProgramming:. 6 1 2 Array . 1 21 0 1 2 3 4 5 6 7 8 9 10 11 Array 12 Array 3x4 . 1 22 0 1 2 3 4 5 6 7 8 9 10 11 int *a; a = new int [ 3 x 4 ]; 2D a[1][2] a[ i ][ j ] 1D a[6] = a[ 1 x 4 + 2 ] a[ 1 x col + j] . 1 23 0 1 2 3 0 1 2 0 1 2 3 4 5 6 7 8 9 10 11 1 Dynamic Array () . 1 24
  7. 7. 01/11/56 AdvanceComputerProgramming:. 7 1 Dynamic Array () . 1 25 Error 1 Dynamic Array () . 1 26 a Pointer 1 Code Function . 1 27 2 Code Function . 1 28 Get Array 2D Get Array 2D a [ ] col row col row a [ ] Argument Return Argument Return 1 2
  8. 8. 01/11/56 AdvanceComputerProgramming:. 8 : Array Pointer 1 1 Get Array 2D a [ ] col row 2 Code Function . 1 30 1 arr main *a 2 Code Function . 1 31 1 MainMain Prototype : Function 2 Code Function . 1 32 1 Function Main a === &arr *a === arr row === &r *row === r Function Address arr
  9. 9. 01/11/56 AdvanceComputerProgramming:. 9 2 Code Function . 1 33 2 2 Code Function . 1 34 2 ( 1) Return a 2 Code Function . 1 35 2 MainMain