Create an “empty” dynamic 2-D array?

August 11th, 2010 posted by admin


Write a C function function create() that creates an “empty” dynamic 2-dimensional array with the number of rows given by its first argument (called rows) and the number of columns given by its second argument (called columns). If the value of ‘columns’ is < 1, then pretend that the value of 'columns' is 1, if the value of 'rows' is < 1, than pretend that the value of 'rows' is 1. The dynamic array is created using malloc() function and if an error during memory allocation occurs, the whole program (not just the function create()) must be terminated with an error message "memory allocation error". Leave the content of the array "undefined", i.e. leave the 'junk' there.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Facebook
  • TwitThis

Email newsletter related posts: