// Driver to test 2d array functions #include "array2d.h" int main(int argc, char *argv[]) { if (argc != 3) { fprintf(stderr, "Usage: %s rows cols\n", argv[0]); return -1; } const int rows = atoi(argv[1]); const int cols = atoi(argv[2]); // Create an array and fill with values from zero up double ** array = array2dAlloc(rows, cols); for (int r = 0; r < rows; ++r) { for (int c = 0; c < cols; ++c) { array[r][c] = r * cols + c + .5; } } array2dDisplay(array, rows, cols); /* Comment out these two lines until you implement transpose */ array = array2dTranspose(array, rows, cols); array2dDisplay(array, cols, rows); array2dFree(array); // Do again, with rows and cols reversed, half as many cols const int rows2 = cols/2; const int cols2 = rows; array = array2dAlloc(rows2, cols2); for (int r = 0; r < rows2; ++r) { for (int c = 0; c < cols2; ++c) { array[r][c] = r * cols2 + c + .1; } } array2dDisplay(array, rows2, cols2); array2dFree(array); return 0; }