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
Explain what is the difference between functions abs() and fabs()?
what are the 10 different models of writing an addition program in C language?
Why #include is used in c language?
What are the keywords in c?
What is the benefit of using an enum rather than a #define constant?
What's the best way of making my program efficient?
Explain how can I prevent another program from modifying part of a file that I am modifying?
What does c mean before a date?
What is c definition?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
What does %p mean c?
What are pragmas and what are they good for?
What are the scope of static variables?
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
What is the purpose of void pointer?