topical media & game development

talk show tell print

professional-program-13-CharacterBoard-CharacterBoard.c

? / professional-program-13-CharacterBoard-CharacterBoard.c


  char** allocateCharacterBoard(int xDimension, int yDimension)
  {
    char** myArray = new char*[xDimension]; //  Allocate first dimension
  
    for (int i = 0; i < xDimension; i++) {
      myArray[i] = new char[yDimension];  //  Allocate ith sub-array
    }
  
    return myArray;
  }
  
  void releaseCharacterBoard(char** myArray, int xDimension)
  {
    for (int i = 0; i < xDimension; i++) {
      delete[] myArray[i];    //  Delete ith sub-arraysubarray
    }
  
    delete[] myArray;           //  Delete first dimension
  } 
  
  int main(int argc, char** argv)
  {
    char** board = allocateCharacterBoard(7, 13);
    releaseCharacterBoard(board, 7);
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.