Hi iam facing the problem while compiling the below program,
program.h ------------headerfile
typedef struct
{
unsigned char c ;
unsigned int i ;
unsigned long l ;
}data_t ;
program.cc ------c++ file
# include <iostream>
# include <malloc.h>
using namespace std ;
# include "ptr.h"
int main()
{
data_t data[] =
{
{'A',1,10},
{'B',2,11},
{'C',3,12}
} ;
data_t *ptr = &data[0] ;
data_t *ptr = &data[1] ;
cout<<"ptr->c"<<ptr->c<<"ptr->i"<<ptr->i<<"ptr->l"<<ptr->l ;
return 0 ;
}
i am getting below errors while compiling
error : redclaration of data_t *ptr
error : data_t *ptr previously declared here
so can i allocate memory for ptr before data_t *ptr = &data[1] ; statement, if this is the case please provide me allocating memory for ptr using new operator.