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
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
Are pointers integer?
What are unions in c?
Why we use break in c?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
praagnovation
What do you mean by invalid pointer arithmetic?
What is difference between Structure and Unions?
Why is structure padding done in c?
explain what are pointers?
What is spaghetti programming?
How can I prevent another program from modifying part of a file that I am modifying?
Explain how can a program be made to print the name of a source file where an error occurs?
Explain how do you list files in a directory?
Are c and c++ the same?