• Home
  • Genetik
  • Google
  • Links
  • About
  • Yohan Naftali

    Two Dimensional Array

    May. 19, 2009

    This article demonstrate how to passing parameter of two dimensional array (C++ languange);
    Artikel ini menjelaskan bagaimana melakukan passing parameter untuk array 2 dimensi (bahasa C++);

    // Author: Yohan Naftali
    // Prototype
    void myFunction(long double (*myArray)[noRow]);
    //Global Variable
    const int NoRow = 10;
    const int NoCol = 10; //for array 10×10
    void main()

    {
    // Array Declaration, this is my style for defining array,
    // you may coding with different way
    long double (*myArray)[NoRow];
    myArray = new long double [NoCol][NoRow];
    // Call myFunction array
    myfunction(myArray);
    // After function called, hence myArray already filled with 1,
    // just continue your code as you need
    }
    void myFunction(long double (*myArray)[NoRow])
    {
    for (int i = 0; i < NoCol; i++) {
    for (int j = 0; j < NoRow; j++ {
    myArray[i][j] = 1.;
    }
    }
    }
    // Happy programming…;


    Share on Facebook Delicious Bookmark this on Delicious

    Leave a Reply