Examveda

How do you allocate a matrix using a single pointer in C?(r and c are the number of rows and columns respectively)

A. int *arr = malloc(r * c * sizeof(int));

B. int *arr = (int *)malloc(r * c * sizeof(int));

C. int *arr = (int *)malloc(r + c * sizeof(int));

D. int *arr = (int *)malloc(r * c * sizeof(arr));

Answer: Option B


This Question Belongs to Data Structure >> Arrays In Data Structures

Join The Discussion

Related Questions on Arrays in Data Structures