Answer Posted / rajendra
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */
#include <errno.h>
#include <stdio.h>
#define ROW 5
#define COL 5
int
main ( void )
{
int **cont_arr;
int **cont_arr;
int **arr = malloc ( ROW * sizeof ( int * ) );
if ( !arr )
{
perror ( "Error" );
exit ( EXIT_FAILURE );
}
for ( i=0; i < ROW; i++ )
{
arr[i] = malloc ( sizeof ( int ) * COL );
if ( !arr[i] )
{
perror ( "Error" );
exit ( EXIT_FAILURE );
}
}
/*
* Contiguous memory allocated for array.
Below.
*/
cont_arr = (int **) malloc ( ROW * sizeof ( int
* ) );
if ( !cont_arr )
{
perror ( "Error" );
exit ( EXIT_FAILURE );
}
cont_arr[0] = (int *) malloc ( ROW * COL *
sizeof ( int ) );
if ( !cont_arr[0] )
{
perror ( "Error" );
exit ( EXIT_FAILURE );
}
for ( int i=1; i < ROW; i++ )
cont_arr[i] = cont_arr[0] + i * COL;
exit ( EXIT_SUCCESS );
}
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
Why do we use stdio h and conio h?
What is the process of writing the null pointer?
What is c++ used for today?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
What are the functions to open and close file in c language?
What are reserved words?
explain what is fifo?
Describe newline escape sequence with a sample program?
Explain the difference between call by value and call by reference in c language?
How can I recover the file name given an open stream?
a program that can input number of records and can view it again the record
Explain do array subscripts always start with zero?
What is dynamic dispatch in c++?
find the sum of two matrices and WAP for it.
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER