I wanted to convert two dimensional array to a one dimension (array linearization ) by using a pointer and setting it to a particular character. Here is the code:
#define COLS 20
#define ROWS 10
void convert(void)
{
char record[ROWS][COLS] = { 0 };
char *pRecord = record;
int i = 0;
for (i = 0; i < (ROWS*COLS); i++)
{
*(pRecord++) = ' ';
}
}
However, I am getting a compiler error in initializing the pointer to char
array. I 'vd edited the code i.e it will be *pRecord, previously it was only pRecord. Need some help in understanding the error and if possible some suggestions to fix it.