Thursday, July 30, 2009

Write a C program?

Write a C function addr() that has three arguments, the first is a pointer to a two dimensional dynamic array, the second is an integer that describes the number of its rows, the third argument is an integer that describe its number of columns.


Function addr() adds one new row (as the last one) to the dynamic array using realloc(). It returns the pointer to the new (possibly reallocated) array.





int **addr(int **p,int rows,int columns);

Write a C program?
I don't see a point in returning the pointer to the array that is already pointed to by p. You could return success or failure which could help the caller in knowing whether the array was really realloc'd.





homework? ;)


read man realloc on a Unix/Linux machine


No comments:

Post a Comment