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
I need previous papers of CSC.......plz help out by posting them.......
Describe the order of precedence with regards to operators in C.
What is advantage of pointer in c?
How can you draw circles in C?
What is self-referential structure in c programming?
What is a loop?
Explain what are linked list?
How can you determine the size of an allocated portion of memory?
How are strings stored in c?
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
What is keyword in c?
What are the types of data types and explain?
What are bitwise shift operators in c programming?
Can we replace the struct function in tree syntax with a union?