T
tommyPrep
The discussion is in reference with the following code :
#include <stdio.h>
#include <stdlib.h>
#define MAXCOLS 10
int main()
{
int (*a)[MAXCOLS];
int nrows,ncols,i;
scanf("%d",&nrows);
scanf("%d",&ncols);
/* allocate intial memory */
*a = (int *) malloc( sizeof(int));
/* Code continued */
}
While compiling this code it is giving error like
"Incompatible types in assingment"
This is probably the rvalue is returning int *
but the lvalue is expecting int [].
I have tried different options but some of them are compiling
with a warning in some compilers while in some it is giving error.
Can any one please let me know how to rectify this.
#include <stdio.h>
#include <stdlib.h>
#define MAXCOLS 10
int main()
{
int (*a)[MAXCOLS];
int nrows,ncols,i;
scanf("%d",&nrows);
scanf("%d",&ncols);
/* allocate intial memory */
*a = (int *) malloc( sizeof(int));
/* Code continued */
}
While compiling this code it is giving error like
"Incompatible types in assingment"
This is probably the rvalue is returning int *
but the lvalue is expecting int [].
I have tried different options but some of them are compiling
with a warning in some compilers while in some it is giving error.
Can any one please let me know how to rectify this.