def CreateCArray(c_type, dimensions):
   """Creates a ctypes array with the specified dimentions.
   
   The dimensions should be specified in a list. For example, to create a 3 element array, write:
   
   [3]
   
   and to create a 3 by 2 array, write:
   
   [3, 2]

   Note, the array will be created such that accesses to it will be row-major.

   Parameters
   c_type -- A class identifier specifying the type of each element in the array. For example, c_int or c_double.
   Dimensions -- A list containing the dimensions of the array to create.
   
   Return Value
   An object representing an instance of the specified array.
   
   """
   # Create the type
   arrayType = c_type * dimensions[-1:][0]
   remainingDimensions = dimensions[:-1]
   remainingDimensions.reverse()
   for dimension in remainingDimensions:
      arrayType = arrayType * dimension
   
   # Create an instance and return it
   arrayInstance = arrayType()
   return arrayInstance