I'm using apple LLVM compiler for C++ development in Xcode. I initialise the char pickbuf
variable and allocate the required memory I want to assign value 1 to second code of line there. But I'm getting a null pointer error: please help me.
2DCDP4.h
class CDP : public Const2DCDP{
struct PICK
{
short x; // Transverse connector
short y; // Vertical direction consolidated
unsigned char x0; // Transverse reduction limit
unsigned char y0; // Longitudinal reduction limit
} ;
public:
char* pickbuf =new char[1]; // Overlapping buffer allocate some
PICK* pickup =new PICK [1]; // Backtrace buffer
}
void getProjection(void);
};
2DCDP4.cpp
#include "2DCDP4.h"
void CDP::getProjection(void){
char *before=pickbuf;
if( before[(j-1)*di + (i-1)] == 1) //**Thread 1 : EXC_BAD_ACCESS (Code = 1, address = 0x0)**
{
//code
}
}